栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

hive--DQL

hive--DQL

Hive--DQL 内置运算符
  • 查看函数

  • 关系运算符

    • 大小比较

    • 空值判断

    • 模糊查询

    • 正则查询

  • 算数运算符

    • 加减乘除

    • 取整取余

    • 位运算

  • 逻辑运算符

    • 与或非

     
      
    • 在范围内

     
内置函数
  • 字符串函数

 
  • 时间日期函数

 
  • 数学函数

 
  • 集合函数

 
  • 条件函数

 
  • 类型转换

 
  • 数据脱敏

 
  • 其他

 
自定义函数(UDF)(了解) 
  • UDF

  • UDAF

  • UDTF

Hive函数进阶
  • explode(UDTF)

    • NBA总冠军球队

    create table the_nba_championship(
        team_name string,
        champion_year array
    ) row format delimited
    fields terminated by ','
    collection items terminated by '|';
    
  • lateral View

  • 行列转换

    • 列转行

    create table row2col2(
       col1 string,
       col2 string,
       col3 int
    )row format delimited fields terminated by 't';
    
    • 行转列

    create table col2row2(
       col1 string,
       col2 string,
       col3 string
    )row format delimited fields terminated by 't';
    
  • json数据处理

    • 单个

    create table tb_json_test1 (
      json string
    );
    
    • 多个

    create table tb_json_test2 (
       device string,
       deviceType string,
       signal double,
       `time` string
     )
    ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
    STORED AS TEXTFILE;
    
    • serder

    create table tb_json_test2 (
       device string,
       deviceType string,
       signal double,
       `time` string
     )
    ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
    STORED AS TEXTFILE;
    

窗口函数
  • 建表

---建表并且加载数据
create table website_pv_info(
   cookieid string,
   createtime string,   --day
   pv int
) row format delimited
fields terminated by ',';

create table website_url_info (
    cookieid string,
    createtime string,  --访问时间
    url string       --访问页面
) row format delimited
fields terminated by ','
  • 求出每个用户总pv数sum+group by普通常规聚合操作

 
  • 求出网站总的pv数 所有用户所有访问加起来

 
  • 求出每个用户总pv数

 
  • 求出每个用户截止到当天,累积的总pv数

 
  • 第一行到当前行

 
  • 找出每个用户访问pv最多的Top3重复并列的不考虑

 
  • 统计每个用户pv数最多的前3分之1天

 
  • lag

 
  • lead

 
  • first_value()

 

  • last_value()

 

数据压缩
  • 压缩算法

数据存储格式
  • 行存储和列存储

  • TextFILE

  • ORC

  • PAROUET

  • 格式对比

  • 查询速度对比

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/335612.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号