hive sql 笔记

  • cast 强制类型转换
    cast(info as BIGINT)

  • concat_ws 字符串的链接
    concat_ws('-',year,month,day)

  • split 字符串的分割
    split(info,',')

  • lateral view explode 字符串的延展
    lateral view explode(split(param['info'],'\;')) snTable as split_info

  • unix_timestamp 日期转毫秒
    (unix_timestamp(start_time)-unix_timestamp(end_time))/60 (分钟)

  • case
    case when a>1 then 1 when a>=1 and a<2 then 2 else 3 end as tmp

  • from_unixtime 毫秒转日期
    from_unixtime(1511022000,'yyyy-MM-dd HH:mm:ss')

  • select 未命名的列 _c0
    select sum(_c0) from table

  • 得到行号 row_umber()
    select name, row_umber() over() from stu_table;

  • 展示一个表创建时候的信息
    show create table student_talbe;

  • 查看一个表的所有的字段名
    show full columns from question

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,136评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,406评论 0 23
  • 只身步步海天涯,路无归,霜满颜。 ——题记 “母亲的背佝偻得更...
    绯蔚阅读 2,761评论 0 5
  • 文/云弋 我是神仙的花匠在人间种鲜花在天上种烟花——《今天的三行诗》 曾有一段时间,人间无日无月,凡人生息全凭灯火...
    云弋阅读 4,597评论 5 9
  • 冬日暖阳 认识慧娟的时候,我的日子正一团的糟。事业上,屡屡不顺。家庭也是一地鸡毛。 本科院校毕业的我应聘到了300...
    j冬日暖阳阅读 3,382评论 0 0