Presto常用udf
Presto使用的一些udf和hive差异比较大, 特此记录一下 测试环境:0.188
时间处理相关
-
将unix时间戳转成时间字符串
select format_datetime(from_unixtime(1542114000), 'yyyy-MM-dd-HH-mm-ss') from dual;
format_datetime使用的日期格式化是跟Java保持一致的 -
将时间字符串转成unix时间戳
select cast(to_unixtime(date_parse('2018-11-14-01-00-00', '%Y-%m-%d-%H-%i-%s')) as bigint) from dual;
date_parse使用日期格式化是Mysql的规范 (MySQL Date Functions), 能不能统一点?
数组相关
-
数组的大小
select cardinality(array_col) from dual;
为了使用这个, 多记住了一个数学名词的拼写 势 -
数组的索引值起始是1 !!!
select my_array[1](array_col) from dual;