zoukankan      html  css  js  c++  java
  • 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;
    
    
    

    以下是运行结果截图:

  • 相关阅读:
    变量定义方法
    动态编译
    函数
    过程
    触发器
    高级聚合函数rollup(),cube(),grouping sets()
    高级函数-decode
    高级函数-sign
    js 保留两位小数 javascript
    js 发红包
  • 原文地址:https://www.cnblogs.com/lger/p/9048260.html
Copyright © 2011-2022 走看看