hivesql写的时候要注意的点(后续还会补充)

  1. 不能select非group的字段

  2. 当字段值为string的时候,可以用is not null来判断为不为空;当字段值是array的时候,要用size()来判断是不是为空[],用null判断的是全空,连[]也没有的情况

  3. 在hive中支持 in 语法的 ,只是在 in 中不能接一个子查询,所以要in子查询的话,最好写成关联表形式

  4. MD5函数:select md5(orderid) from es.qhlo_borrower_contactinfo where orderid = '6859238';

    说明MD5是个函数,不能写在最外围,必须写在select后面,而且MD5(*)是错的,里面只能是具体的string或者binary

  5. 注意集合一列数据的时候用collect_set加group , 集合多列数据的时候,用array(map()),例如:

    Select

    m.orderid as clientid,

    array(map(

    'clientid',m.orderid,

    -- 'channel_source','1',

    'both_ends','1',

    -- 'customer_channel','1',

    'system_source','84',

    'business_channel','70',

    'source_create_date',m.appSubmissionTime,

    'ct',a.createtime,

    'lt',a.updatetime

    )) as t_pd_will_info

    from

    es.qhlo_apply_applyinfo m

    LEFT JOIN

    es.qhlo a on a.orderid=m.orderid

     

    Hive 的collect_set使用详解

    https://blog.csdn.net/liyantianmin/article/details/48262109   

  6.  

    hive命令行操作:

    su - dev

    hive

    就进入hive了

    set hive.cli.print.header=true;

    在hive命令行执行的时候,一定记得加limit xx;否则数据量太大

    cast(xx as bigint) 表示不以科学数字展示

    use 数据库名;

    show tables ‘*icp*’;模糊搜索表

    desc table 展示表DDL

    nohup hive -hiveconf date='init' -hivevar where='' -f 50confirm.sql > 50confirm.log &

    ds='${hiveconf:date}'

     

     

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值