impala类型转换函数最全版

x33g5p2x  于2021-12-25 转载在 其他  
字(0.5k)|赞(0)|评价(0)|浏览(431)

本文基于impala3.2版本,所有的内置类型转换函数;

一、类型转换函数
序号语法类型/方法名称输出类型使用说明
1cast (expression as type )type的类型把expression转化为type类型,不能转换返回null
2cast (expression as type format pattern)type的类型基于pattern完成数据的类型转换,并返回对应的结果
3typeof (expression)string返回expression对应的数据类型的名称

示例如下:

--使用示例 | 对应输出 | 对应函数序号
cast(1 as string)                                 “1”                       1
cast("02-11-2014" as date format 'dd-mm-yyyy')    2014-11-02                2
typeof(now())                                     TIMESTAMP                 3

第二个函数没有测试成功,具体的格式和pattern适配可以参考:impala-类型转换函数
http://impala.apache.org/docs/build/html/topics/impala_conversion_functions.html

相关文章