hive基本操作与应用

通过hadoop上的hive完成WordCount

  • 启动hadoop
  • Hdfs上创建文件夹
  • 上传文件至hdfs
  • 启动Hive
  • 创建原始文档表
  • 导入文件内容到表docs并查看
  • 用HQL进行词频统计,结果放在表word_count里
  • 查看统计结果

以上的要求实现如下:


start-all.sh
hdfs dfs -put ~/wordcount.txt input/wordcount.txt
hive 

> create database test02;
> create table test02(content string);
> load data inpath '/user/hadoop/input/wordcount.txt' into table test02;
> create table test03 as select word, count(1) as count from (select explode(split(regexp_replace(content, ',|\.', ' ') , ' ')) as word from test02) word group by word;
> select * from test03;


以下是运行结果截图:

原文地址:https://www.cnblogs.com/lger/p/9048260.html