hive函数lateral view explode小实验

SELECT device_name,COO FROM
(
	SELECT device_name,SPLIT(cont,',') AS cont 
	FROM
	(
		SELECT 'ALP-AL00' AS device_name,'a,b,c,d'  AS cont UNION ALL
		SELECT 'BLN-AL10' AS device_name,'Q,W,E,R'  AS cont
	)T
)A lateral view explode(cont) adtable AS COO 

中间表T表数据:

+------------------+-----------+--+
| _u1.device_name  | _u1.cont  |
+------------------+-----------+--+
| ALP-AL00         | a,b,c,d   |
| BLN-AL10         | Q,W,E,R   |
+------------------+-----------+--+

最终结果:

+--------------+------+--+
| device_name  | coo  |
+--------------+------+--+
| ALP-AL00     | a    |
| ALP-AL00     | b    |
| ALP-AL00     | c    |
| ALP-AL00     | d    |
| BLN-AL10     | Q    |
| BLN-AL10     | W    |
| BLN-AL10     | E    |
| BLN-AL10     | R    |
+--------------+------+--+

你可能感兴趣的:(hive)