Database Reference
In-Depth Information
HDFS Data Loading
We can also load from HDFS in a Hive-managed table using the
load data
com-
mand. Let's explore this part with a simple exercise:
1.
Let's put the tweets file on HDFS using the
put
command:
bin/hadoop fs -put /home/vivek/Documents/
apress_book/Apress/datafiles/person_store
/usr/vivek/employee_store/infile
2.
We can load data directly to the HDFS directory using the
load
command as follows:
load data inpath '/usr/vivek/employee_store/
infile
' overwrite into table
employee ;
The difference here is that it is
load data inpath
in place of
load data local inpath
, which allows mapping from file
path to HDFS directory (e.g.,
/usr/vivek/employee_store/
infile
).
3.
Finally, we can explore inserted data (see
Figure 6-17
):
select * from employee;
4.
We can also use conditional queries such as fetching employees by
name (see
Figure 6-18
):
select * from employee where fname = 'vivek';