sql的explode函數


在查詢數據時,當字段類型為array時候,無法直接查詢這個字段,需要用explode來打開

例如

 

 

 

 查詢clicks字段,需要用explode打開

select local_dt,s.name
from
(
    SELECT local_dt,
                explode(payload.clicks) as s
    from dts_obt.eventtypeclientclick 
    where dt BETWEEN '20200604' and '20200608'
    and local_dt between '20200605' and '20200607'
    and payload.region="BR"
) 

  再例如

 

 

select 
       a.local_dt,
       sum(a.gems_delta)
from 
(select explode(del_items) as s,
       gems_delta,
       local_dt
from ff_facts.exchange_items_facts
where utc_8_dt between "20200115" and "20200119"
and   region = "TW") as a 
where a.gems_delta > 0
and   a.s.id = 400000128
group by a.local_dt
order by a.local_dt

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM