HIVE

Jiacheng 2021-11-28 PM

1、hive语句

1)lateral view explode

-- LATERAL VIEW udtf(expression) tableAlias AS columnAlias (’,’ columnAlias)
tableAlias:表别名
columnAlias:表中的列别名
-- explode() takes in an array (or a map) as an input and outputs the elements of the array (map) as separate rows. 
SELECT explode(myCol) AS myNewCol FROM myTable;

-- Lateral view is used in conjunction with user-defined table generating functions such as explode(). As mentioned in Built-in Table-Generating Functions, a UDTF generates zero or more output rows for each input row. A lateral view first applies the UDTF to each row of base table and then joins resulting output rows to the input rows to form a virtual table having the supplied table alias.
SELECT pageid, adid
FROM pageAds LATERAL VIEW explode(adid_list) adTable AS adid;

-- 例如:增加计算所有类型的数据
LATERAL VIEW explode(array(platform, 'ALL')) col AS platform_all

在正常解析一个有值的字符串时,用lateral view explode是完全ok的,但是,当遇到该字符串为空时,如果在使用该函数,就会导致该条记录消失。具体场景如下:

这样的结果就会导致我们漏掉一部分用户的浏览信息,在统计浏览量时数据缺失,结果与实际偏小。
这时,就要用到lateral view outer explode

标签: none

非特殊说明,本博所有文章均为博主原创。

评论啦~



已有 11 条评论


  1. brrssrqrll
    brrssrqrll

    叼茂SEO.bfbikes.com

    回复 2024-09-22 22:14
  2. rutkdtjhkc
    rutkdtjhkc

    想想你的文章写的特别好

    回复 2024-09-23 08:57
  3. zhsbupijpz
    zhsbupijpz

    看的我热血沸腾啊www.jiwenlaw.com

    回复 2024-10-05 19:54
  4. ojoaanbvpq
    ojoaanbvpq

    哈哈哈,写的太好了https://www.cscnn.com/

    回复 2024-10-19 14:27
  5. wsvfxadnlw
    wsvfxadnlw

    兄弟写的非常好 https://www.cscnn.com/

    回复 2024-10-19 14:27
  6. omotflllnh
    omotflllnh

    《地狱少女》恐怖片高清在线免费观看:https://www.jgz518.com/xingkong/10582.html

    回复 2024-11-25 20:40
  7. otunfkjvnz
    otunfkjvnz

    《浪荡儿1953》喜剧片高清在线免费观看:https://www.jgz518.com/xingkong/120658.html

    回复 2024-11-29 04:14
  8. ufrdcbatgs
    ufrdcbatgs

    《虎胆龙威合辑(豪华特别版)》动作片高清在线免费观看:https://www.jgz518.com/xingkong/148033.html

    回复 2024-12-26 03:28
  9. wjwqhtyymt
    wjwqhtyymt

    《少年骇客:全面进化第一季》欧美动漫高清在线免费观看:https://www.jgz518.com/xingkong/7414.html

    回复 2025-01-03 03:05
  10. wenblzyxqx
    wenblzyxqx

    哈哈哈,写的太好了https://www.lawjida.com/

    回复 2025-01-06 13:43
  11. zaxwmujclt
    zaxwmujclt

    哈哈哈,写的太好了https://www.lawjida.com/

    回复 2025-01-06 13:43