HIVE内置函数列表
文章目录
Hive的内置函数列表。下面是这些函数按类别归纳后的简要说明:
数学函数
abs: 绝对值acos: 反余弦asin: 反正弦atan: 反正切cbrt: 立方根ceil,ceiling: 向上取整cos: 余弦exp: 指数floor: 向下取整log,log10,log2: 对数pi: 圆周率pow,power: 幂radians: 弧度rand: 随机数round: 四舍五入sign: 符号函数sin: 正弦sqrt: 平方根tan: 正切
字符串函数
ascii: 返回字符的ASCII码base64: Base64编码bin: 二进制表示concat,concat_ws: 连接字符串decode: 解码encode: 编码find_in_set: 查找字符串在集合中的位置format_number: 格式化数字hex: 十六进制表示initcap: 单词首字母大写instr: 查找子字符串位置length: 字符串长度lower,lcase: 转为小写lpad: 左填充ltrim: 左侧去空格repeat: 重复字符串reverse: 反转字符串rpad: 右填充rtrim: 右侧去空格space: 生成空格字符串split: 分割字符串substr,substring: 截取子字符串translate: 替换字符trim: 去空格upper,ucase: 转为大写
日期函数
add_months: 增加月份current_date: 当前日期current_timestamp: 当前时间戳date_add: 增加天数date_format: 日期格式化date_sub: 减少天数datediff: 计算日期差day,dayofmonth: 天from_unixtime: 从Unix时间戳转换from_utc_timestamp: 从UTC时间戳转换hour: 小时last_day: 月的最后一天minute: 分钟month: 月份months_between: 月份差next_day: 下一个指定的工作日second: 秒to_date: 转换为日期to_unix_timestamp: 转换为Unix时间戳to_utc_timestamp: 转换为UTC时间戳unix_timestamp: 当前Unix时间戳weekofyear: 年的第几周year: 年
聚合函数
avg: 平均值collect_list: 聚合为列表collect_set: 聚合为集合corr: 相关系数count: 计数covar_pop: 人口协方差covar_samp: 样本协方差first_value: 第一个值last_value: 最后一个值max: 最大值min: 最小值percentile,percentile_approx: 百分位数std,stddev,stddev_pop,stddev_samp: 标准差sum: 求和var_pop: 人口方差var_samp: 样本方差variance: 方差
条件函数
and: 逻辑与between: 在某范围内case: 条件判断if: 条件判断in: 在集合内not: 逻辑非or: 逻辑或when: 条件判断
其他函数
array,array_contains: 数组操作compute_stats: 计算统计context_ngrams: 上下文N-gramcreate_union: 创建联合current_database: 当前数据库current_user: 当前用户decode,encode: 编码解码ewah_bitmap,ewah_bitmap_and,ewah_bitmap_empty,ewah_bitmap_or: EWAH位图操作explode,posexplode: 展开数组或映射field: 字段get_json_object: 从JSON中获取对象histogram_numeric: 数值直方图json_tuple: 从JSON中获取元组levenshtein: Levenshtein距离like: 模糊匹配map,map_keys,map_values: 映射操作noop,noopstreaming,noopwithmap,noopwithmapstreaming: 无操作函数parse_url,parse_url_tuple: 解析URLreflect,reflect2: 反射调用regexp,regexp_extract,regexp_replace,rlike: 正则表达式操作sentences: 句子分割sort_array: 排序数组soundex: Soundex编码stack: 堆栈str_to_map: 字符串转换为映射struct: 结构体uuid: 生成UUIDversion: Hive版本信息xpath,xpath_boolean,xpath_double,xpath_float,xpath_int,xpath_long,xpath_number,xpath_short,xpath_string: XPath查询
特殊操作符
!,!=: 不等于%: 取模&: 按位与*: 乘+: 加-: 减/: 除<,<=: 小于,小于等于<=>,<>: 不等于=: 等于>,>=: 大于,大于等于^: 按位异或|: 按位或~: 按位非
这是一个详细的Hive内置函数的列表。你可以根据具体需要使用相应的函数来进行数据处理和查询操作。如果你对某个函数的具体用法不清楚,可以参考Hive的官方文档或使用DESCRIBE FUNCTION命令来获取详细信息。
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论