栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Presto 和 Hive 的sql语句(函数)的切换使用(不断更新中...)

Presto 和 Hive 的sql语句(函数)的切换使用(不断更新中...)

presto 与 hue 的切换使用
```bash
Hive:collect_set转为数组并去重,concat_ws将数组用逗号间隔连接成字符串

select 
  user_id, 
  concat_ws(',', collect_set(order_id)) as order_ids
from test_table
where 1 = 1
group by user_id ;

Presto:array_agg转为数组,array_distinct去重,array_join将数组用逗号间隔连接成字符串

select 
  user_id, 
  array_join(array_distinct(array_agg(order_id)), ',') as order_ids
from test_table
where 1 = 1
group by user_id ;

hive    to_date('2021-12-13 10:36:28')     结果  2021-12-13
presto  substr('2021-12-13 10:36:28',1,10) 结果  2021-12-13

hive    nvl()
presto  coalesce()

hive    cast(字段 as string)
presto  cast(字段 as varchar)


hive    get_json_object()
presto  json_array_get() 和 json_extract()

json_array_get()取出jsonArray的第一个元素
    select
      json_array_get(xjson,0)
    from 
    test_table

json_extract 和 hive中的get_json_object类似
select
  json_extract('{"mid":"1001","alternate":"1"}', '$.alternate')
from
  test_table
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/672771.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号