对于hql中拼接字符串的函数使用

2022-02-25  本文已影响0人  安申

背景:在工作过程中,一直经常性接触到hql拼接字符串的工作内容,但每次都是最常规的拼接,效率并不高。故调研发现hive早已提供相关函数进行更简便处理。

  1. named_struct
  1. collect_list(可重复) 与collect_set(不可重复)
select
'id',
collect_list(json)
from
(select 'id',named_struct("name","color","age",18) as json 
union all
select 'id',named_struct("name","Doull","age",19) as json)t
group by 'id';
arr
  1. concat_ws
  1. concat
上一篇 下一篇

猜你喜欢

热点阅读