我们沿用之前hadoop wordcount的结果数据:
[hadoop@icity0 ~]$ hadoop fs -cat /wc/out/part-r-00000
Warning: $HADOOP_HOME is deprecated.
beautiful 1
day 1
dear 2
hello 2
hometown 1
honey 2
is 2
my 2
one 1
sunny 1
this 1
today 1
world 3
现在我们在hive上新建一张wordcount的数据表,然后将hdfs 中的/wc/out/part-r-00000数据导入到hive中:
cd hive/bin
./hive
CREATE TABLE wordcount(name string,id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
LOAD DATA INPATH 'hdfs://icity0:9000/wc/out/part-r-00000' INTO TABLE wordcount;
查询wordcount数据表:
统计wordcount 数据表中的不同的单词个数,及count
从这个结果中,其实可以看出,我们之前所说的结论:
查询是通过MapReduce来完成的(并不是所有的查询都需要MapReduce来完成,比如select * from XXX就不需要;