hive lateral view 函数

lateral view 结合 explode 可以实现将 一行转化为行的功能

INSERT OVERWRITE TABLE ${eventAtributesTable} PARTITION (hp_stat_date = '$date')
 SELECT page_attributes.atime/1000, page_attributes.page_id, page_attributes.username,
   page_attributes.account, page_attributes.action, page_attributes.category, page_attributes.plat, page_attributes.domain,
   page_attributes.ralg, page_attributes.uniqueKey, item,
    from_unixtime(page_attributes.atime/1000, 'YYYY-MM-dd')
 FROM log
 lateral view explode(page_attributes.item) log  as item
 WHERE abnormal_flag = false and (page_attributes.action = "expose" or action == "click")
 

具体可参考:

http://www.cnblogs.com/ggjucheng/archive/2013/01/03/2842938.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容