we can load a file into a hive table in 2 ways
i)using load command
ii)copying file from local into path of the table in hive warehouse.
ii)copying data from local into hive table
------------------------------------------
$cat > file2
My students are legends!!!!!
[cloudera@quickstart ~]$ hadoop fs -put file2 /user/hive/warehouse/tab5/
In hdfs
$hadoop fs -ls /user/hive/warehouse/tab5/
/user/hive/warehouse/tab5/file1
/user/hive/warehouse/tab5/file2
hive>select *from tab5;
My Name is Manohar!!!
My students are legends!!!!
Appending data a file in a hive table
-------------------------------------
if we load same file multiple times without overwriting then the files are appended to a hive a table as shown below.
hive>load data local inpath 'file1' into table tab5;
hive>load data local inpath 'file1' into table tab5;
In hdfs,
$hadoop fs -ls /user/hive/warehouse/tab5
/user/hive/warehouse/tab5/file1
/user/hive/warehouse/tab5/file1_copy_1
/user/hive/warehouse/tab5/file1_copy_2
/user/hive/warehouse/tab5/file2
Here file1 is appended in hdfs with a suffix
_copy_1
_copy_2
..
..
i)using load command
ii)copying file from local into path of the table in hive warehouse.
ii)copying data from local into hive table
------------------------------------------
$cat > file2
My students are legends!!!!!
[cloudera@quickstart ~]$ hadoop fs -put file2 /user/hive/warehouse/tab5/
In hdfs
$hadoop fs -ls /user/hive/warehouse/tab5/
/user/hive/warehouse/tab5/file1
/user/hive/warehouse/tab5/file2
hive>select *from tab5;
My Name is Manohar!!!
My students are legends!!!!
Appending data a file in a hive table
-------------------------------------
if we load same file multiple times without overwriting then the files are appended to a hive a table as shown below.
hive>load data local inpath 'file1' into table tab5;
hive>load data local inpath 'file1' into table tab5;
In hdfs,
$hadoop fs -ls /user/hive/warehouse/tab5
/user/hive/warehouse/tab5/file1
/user/hive/warehouse/tab5/file1_copy_1
/user/hive/warehouse/tab5/file1_copy_2
/user/hive/warehouse/tab5/file2
Here file1 is appended in hdfs with a suffix
_copy_1
_copy_2
..
..
No comments:
Post a Comment