Chinaunix首页 | 论坛 | 博客
  • 博客访问: 656939
  • 博文数量: 149
  • 博客积分: 3901
  • 博客等级: 中校
  • 技术积分: 1558
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-16 14:33
文章分类

全部博文(149)

文章存档

2014年(2)

2013年(10)

2012年(32)

2011年(21)

2010年(84)

分类: 服务器与存储

2010-12-17 11:22:16



Hive  原始的  列传行 方法 

 

Array myCol

[1,2,3]

[4,5,6]

Then running the query:

SELECT explode(myCol) AS myNewCol FROM myTable;

Will produce:

int myNewCol

1

2

3

4

5

6

 

 

Using the syntax "SELECT udtf(col) AS colAlias..." has a few limitations:

  • No other expressions are allowed in SELECT
    • SELECT pageid, explode(adid_list) AS myCol... is not supported
  • UDTF's can't be nested
    • SELECT explode(explode(adid_list)) AS myCol... is not supported
  • GROUP BY / CLUSTER BY / DISTRIBUTE BY / SORT BY is not supported
    • SELECT explode(adid_list) AS myCol ... GROUP BY myCol is not supported

 

 

 

 

 

# 当前  推广码 hql 语句,结果和 当前 pvinsight 的比较像,原代码正在看,可能细节逻辑需要注意下。

 

71.122  hive pvlog 上运行过 ,此 hql 结果在  /tmp/lky/channel_pvid


from (

  from (

    select suv,channelid,regexp_extract(url,'.*pvid=(.*?)(&|#|$)',1) as pvid

    from pvlog_pre

    where dt='20101202'  and regexp_extract(url,'.*pvid=(.*?)(&|#|$)',1)!=""

  ) tb LATERAL VIEW explode( tb.channelid ) adTable  AS channel

  select                                                                                       

    channel,suv,pvid

) tp

INSERT OVERWRITE LOCAL DIRECTORY '/tmp/lky/channel_pvid'

select tp.pvid,tp.channel,count(1) as pv , count (distinct tp.suv )

group by tp.pvid,tp.channel

阅读(5032) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-12-17 15:01:50

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com