赞
踩
1、hive explode函数可以将一个array或者map展开,其中explode(array)使得结果中将array列表里的每个元素生成一行;explode(map)使得结果中将map里的每一对元素作为一行,key为一列,value为一列,一般情况下,直接使用即可,但是遇到以下情况时需要结合lateral view 使用。
1、No other expressions are allowed in SELECT
SELECT pageid, explode(adid_list) AS myCol... is not supported
2、UDTF's can't be nested
SELECT explode(explode(adid_list)) AS myCol... is not supported
3、GROUP BY / CLUSTER BY / DISTRIBUTE BY / SORT BY is not supported
SELECT explode(adid_list) AS myCol ... GROUP BY myCol is not supported
2、使用方法
SELECT
myCol1, myCol2
FROM
baseTable
LATERAL
VIEW
explode(col1) myTable1
AS
myCol1
LATERAL
VIEW
explode(col2) myTable2
AS
myCol2;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。