zoukankan      html  css  js  c++  java
  • Hive进阶_内置函数

     Hive数学函数

    round : 四舍五入

    ceil : 向下取整

    floor : 向上取整

    select round(45.926,2),round(45.926,1),round(45.926,0),round(45.926,-1),round(45.926,-2);

     Hive字符函数

    select lower('Hello World'), upper('Hello World');
    select length('Hello World'),length('你好');
    select concat('Hello','World');
    select substr('Hello World',3);
    select substr('Hello World',3,4);
    select lpad('abc',10,'*'),lpad('abc',10,'*');

    Hive收集函数和转换函数

    size
    cast
    select size(map(1,'Tom',2,'Mary'));
    select cast(1 as bigint);
    select cast(1 as float);
    select cast('2015-04-10' as date);

     

    Hive日期函数

    to_date
    year
    month
    day
    weekofyear
    datediff
    date_add
    date_sub

     Hive条件函数

    coalesce:从左到右返回第一个不为null的值。
    case... when...:
    case a when b then c [when d then e]* [else if] end
    i.e.
    select ename,job,sal,
        case job when 'persident' then sal+1000,
                 when 'manager' then sal+800,
                 else sal+400
        end
    from emp;

    Hive聚合函数和表生成函数

    聚合函数 countsumminmaxavg
    表生成函数 explode
    select count(*),sum(sal),max(sal),min(sal),avg(sal) from emp;
    select explode(map(1,'Tom',2,'Mary',3.'Mike'));

     

  • 相关阅读:
    qt的.pro配置总结
    【GOJ 1489】Monster Hunter
    CPU 杂谈
    【CF 1061C|GOJ 3505】Multiplicity
    【CF 1039D|GOJ 3502】You Are Given a Tree
    我跳过的坑
    【CF 1101D|GOJ 3501】GCD Counting
    【HDU 5269|GOJ 739】xor的最低位
    beta阶段组间的140字互评
    【第七周】【新蜂站会】3
  • 原文地址:https://www.cnblogs.com/liupuLearning/p/6344322.html
Copyright © 2011-2022 走看看