Hive高级用法汇总

1. 根据字符串分割实现一行变多行

关键字:LATERAL VIEW, explode,split

SELECT ad_time_slice_index, SUM(impression_count) FROM base_tracking_logs LATERRAL VIEW EXPLODE(SPLIT(ad_time_slices,'\\,')) adalias AS ad_time_slice_index WHERE dt='2015-08-01' AND hour='00' AND ad_time_slices='1,2,3,4,5,6' GROUP BY ad_time_slice_index;
OK
2    51
3    51
4    51
5    51
6    51
1    51

 

转载于:https://www.cnblogs.com/zhouweihit/p/4720526.html

你可能感兴趣的:(Hive高级用法汇总)