Hive查詢 Hive Join和Hive集合操作

2021-10-09 13:13:17 字數 2440 閱讀 3274

hive join

hive集合操作(union)

#查詢顧客表中地區為「ny」所在城市為'new york'的使用者

select * from customers where customer_state=

"ny" and customer_city=

"new york"

;#查詢訂單表中共有多少不同顧客下過訂單

select count(distinct order_customer_id) from orders;

#查詢商品表中前5個商品

select * from (select * from employee) a;
#使用列匹配正規表示式需要進行設定

set hive.support.quoted.identifiers = none;

#列匹配正規表示式查詢

set hive.auto.convert.join=true(預設值)
執行時自動將連線轉換為mapjoin

-mapjoin操作不支援:

在union all, lateral view, group by/join/sort by /cluster by/distribute by等操作後面

在union, join以及其他 mapjoin之前

Hive高階查詢

select基礎 cte和巢狀查詢 3 高階語句 4 關聯查詢 mapjoin 1 load移動資料 2 insert表插入資料 使用insert語句將資料插入表 分割槽 insert 支援overwrite覆蓋和into追加 hive支援從同乙個表進行多次插入 insert into中table關...

Hive查詢優化

害,最近組裡有個妹子不是很懂sql,一查就等好長時間,看的我十分揪心,算了,寫幾個常見的hive查詢優化叭。1.條目少的表或者子查詢放在join左邊,因為join左邊會讀入記憶體 select a.val b.val from a 條目少 join b on a.key b.key 2.join 操...

Hive查詢優化

1.先過濾,再查詢,因為每次生成中間表都會儲存到linux磁碟上 記住 不是hdfs 2.注意資料傾斜 傾斜的原因是reduce端資料的大量富集,可適度增加reduce 會著開啟 reduce自己判斷 某一比較大 自己再分開點.也就是合理設定 reduce數量 hive.exec.reducers....