hive一些基本操作

  1. 字符串操作
    http://www.cnblogs.com/iiwen/p/5611761.html

  2. 函數大全。
    http://blog.csdn.net/wisgood/article/details/17376393
    函數大全。

  3. hive類型轉化:cast(‘字段1’ as ‘type1’)
    這裏寫圖片描述

  4. in和not in更簡潔的處理方式。
    hql也可以用in和not in,但是1個in或者not in 會產生5個job,其中3個有mapreduce,2個沒有。
    通過以下轉換,將in和not in轉換成1個或者2個job。
    (1).in

select a.col1 
from table1 as a
where 
a.col2 in 
(select col3 from table2 where condition)

改爲:

select a.col1
from table1 as a
left join
table2 as b
on
a.col2=b.col3 where a.col2 is not null;

(2). not in

select a.col1 
from table1 as a
where 
a.col2 not in
(select col3 from table2 where condition)

改爲

select a.col1
from table1 as a
left join
table2 as b
on
a.col2=b.col3 where a.col2 is null;

5.hive連接mongodb的方式
(1). 通過driver連接,通過表mapping
http://blog.csdn.net/thriving_fcl/article/details/51471248

(2). 通過mongodump
http://blog.csdn.net/thriving_fcl/article/details/52503394

(3). 運用hadoop對mongodb數據做mapreduce
http://chenhua-1984.iteye.com/blog/2162576

發佈了101 篇原創文章 · 獲贊 92 · 訪問量 36萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章