@Arslan6and6
2016-09-03T13:26:16.000000Z
字数 825
阅读 932
第七章、大数据仓库Hive深入
[beifeng@hadoop-senior hadoop-2.5.0-cdh5.3.6]$ more sort.txt
hadoop java
mapreduce map
reduce map
yarn history
hadoop yarn
yarn java
[beifeng@hadoop-senior hadoop-2.5.0-cdh5.3.6]$ pwd
/opt/modules/hadoop-2.5.0-cdh5.3.6
hive (test)> create table sort (fieldname string);
load data local inpath '/opt/modules/hadoop-2.5.0-cdh5.3.6/sort.txt' into table sort;
hive (test)> select * from sort;
OK
sort.fieldname
hadoop java
mapreduce map
reduce map
yarn history
hadoop yarn
yarn java
hive (test)> create table words (word string);
//将按行分割后的数据加载入 表words
hive (test)> insert overwrite table words select explode(split(fieldname,'[\t]')) word from sort;
hive (test)> select * from words;
OK
words.word
hadoop
java
mapreduce
map
reduce
map
yarn
history
hadoop
yarn
yarn
java
hive (test)> select word,count(word) count from words group by word;
word count
hadoop 2
history 1
java 1
java 1
map 2
mapreduce 1
reduce 1
yarn 3