• hive常用函数


    1数学函数

    • round(double d)

    • round(double d,int n)

    • floor(double d)

    • ceil(double d)

    • ceiling(double d)

    • rand() 

    • rand(int seed)

    • exp(double d)

    • ln(double d)

    • log10(double d)

    • log2(double d)

    • log(double base,double d)

    • pow(double d,double p)

    • power(double d,double p)

    • sqrt(double d)

    • hex(bigint i)

    • hex(string str)

    • abs(double d)

    • PI()

    2集合函数

    • size(Map<K.V>)

    • map_keys(Map<K.V>)

    • map_values(Map<K.V>)

    • array_contains(Array<T>, value)

    • sort_array(Array<T>)

    3类型转换函数

    • cast(expr as <type>)

    • expression -- 合法的表达式; as 后 type-- 要装换的类型  

      使用CAST函数进行数据类型转换时,在下列情况下能够被接受:


      (1)两个表达式的数据类型完全相同。
      (2)两个表达式可隐性转换。
      (3)必须显式转换数据类型。

    • 举例: cast( '10' as bigint) cast (15/13 as decimal(9,2))--decmal( )中9,2分别是精度与小数位数;

    4日期函数

    • date_add

    • date_sub

    • next_day

    • last_day

    • from_unixtime(bigint unixtime, string format)

    • to_date(string timestamp)

    • year(string date)

    • month(string date)

    • hour(string date)

    • weekofyear(string date)

    • datediff(string enddate, string startdate)

    • add_months(string start_date, int num_months)

    • date_format(date/timestamp/string ts, string fmt)

    5条件函数

    • if(boolean testCondition, T valueTrue, T valueFalseOrNull)

    • nvl(T value, T default_value)

    • COALESCE(T v1, T v2, ...)

    • CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] END

    • isnull( a )

    • isnotnull ( a )

    6字符函数

    • concat(string|binary A, string|binary B...)

    • concat_ws(string SEP, string A, string B...)

    • length(string A)

    • lower(string A) lcase(string A)

    • parse_url(string urlString, string partToExtract [, string keyToExtract])

    • regexp_replace(string INITIAL_STRING, string PATTERN, string REPLACEMENT)

    • reverse(string A)

    • split(string str, string pat)

    • substr(string|binary A, int start) substring(string|binary A, int start)

    7聚合函数

    • count(*)

    • count(expr)

    • count(distinct expr[,expr_.])

    • sum(col)

    • sum(distinct col)

    • avg(col)

    • avg(distinct col)

    • min(col)

    • max(col)

    8表生成函数

      • explode(ARRAY array)

      • explode(MAP map)

      • explode(ARRAY<TYPE> a)

      • json_tuple(STRING jsonStr,p1p2,…,pn)-

      • parse_url_tuple(url,partname1,partname2,…,partnameN)

  • 相关阅读:
    缩减apk大小
    android 的安全问题
    android listview 优化
    Python正则表达式指南
    程序员必须知道的几个国外IT网站
    去掉配置项,开发自信的软件
    去掉配置项,开发自信的软件
    Linux防火墙设置
    Linux防火墙设置
    linux下如何使用sftp命令进行文件上传和下载
  • 原文地址:https://www.cnblogs.com/zhipeng-wang/p/14244745.html
Copyright © 2020-2023  润新知