1.时间格式化
to_char(time,'yyyy-mm-dd hh24:mi:ss'),注意presto中没有MM
2.非空判断
coalesce(l.remark,'空'),类似nvl
3.类型转换
cast(amount as decimal(36.2))
cast(id as varchar)
4.行转列
array_join(array_distinct(array_agg(username)),',')
要求:得到结果 "张三,李四"
| id | username |
| 1 | 张三 |
| 2 | 李四 |
array_agg(expression):将表达式转成数组
array_join(x,','):将X以“,”连接起来
https://blog.youkuaiyun.com/butterfly1009/article/details/54016746
5.替换,拼接函数
concat(substr(mi.realname,1,1),regexp_replace(substr(replace(replace(mi.realname,' ','*'),'·','*'),2), '[\u4E00-\u9FA5A-Za-z0-9_]', '*'))
要求:姓名脱敏
张三-->张*
李四五-->李**
6.日期函数
参考:https://prestodb.github.io/docs/current/functions/datetime.html
博客介绍了Presto中的常用函数,包括时间格式化、非空判断、类型转换、行转列、替换拼接和日期函数等。如时间格式化用to_char,非空判断用coalesce,还给出了各函数的使用示例及部分参考链接。
633

被折叠的 条评论
为什么被折叠?



