1.union 和 union all
- 前者可以去重
select sex,address from test where dt='20210218' union all select sex,address from test where dt='20210218';
+------+----------+--+
| sex | address |
+------+----------+--+
| m | A |
| m | A |
| m | B |
| m | B |
| m | B |
| m | B |
+------+----------+--+
- 后者不會去重
select sex,address from test where dt='20210218' union select sex,address from test where dt='20210218';
+------+----------+--+
| sex | address |
+------+----------+--+
| m | A |
| m | B |
+------+----------+--+
2.sql后面的distribute by , sort by的作用
3.分桶表
clustered by (sno) sorted by (age desc) into 4 buckets
傳入資料只能用insert into /overwrite
2.1.1版本設定了強制分桶操作,因此人為的修改reduce的個數不會影響最終檔案的個數(檔案個數由桶數決定)
–1. 在2.1.1版本里,底層實作了強制分桶,強制排序策略
– 即: 正規寫法要帶上distribute by(分桶欄位)[sort by 排序欄位],如果沒有帶上,也會分桶和排序,
–2. 使用insert into時可以不加關鍵字table. 使用insert overwrite時必須帶關鍵字table.
–3. 因為底層實行了強制分桶策略,所以修改mapreduce.job.reduces的個數,不會影響桶檔案資料,但是會影響真正執行時reduceTask的數量,是真正的reduceTask的數量是最接近mapreduce.job.reduces的數量的因子,如果是素數,就使用本身
4.動態磁區小檔案和OOM優化
INSERT OVERWRITE TABLE ris_relation_result_prod partition(rel_id)
SELECT get_json_object(relation, '$.relationHashcode') AS relation_hashcode,
get_json_object(relation, '$.targetVariableValue') AS target_variable_value,
get_json_object(relation, '$.relId') AS rel_id
FROM ris_relation_old_prod733 where get_json_object(relation, '$.relId') in (**********)
set hive.optimize.sort.dynamic.partition=true;
https://blog.csdn.net/lzw2016/article/details/97818080
5.hive 需要開辟很多記憶體的問題解決
https://blog.csdn.net/qq_26442553/article/details/89343579
問題1: Hive/MR 任務報記憶體溢位

running beyond physical memory limits. Current usage: 2.0 GB of 2 GB physical memory used; 3.9 GB of 4.2 GB virtual memory used. Killing container,
記憶體調優引數:https://blog.csdn.net/sn_zzy/article/details/43115681
6.hive的一些sql優化
https://blog.csdn.net/kwu_ganymede/article/details/51365002
map join優化
7.Hive插入小檔案被kill現象
在hive 插入資料動態磁區時候會產生很多小檔案,被kill, 如下圖1, 另外在GC overhead limit execded

8.Hive處于Block狀態,超時
mapreduce.task.timeout
如果一個task在一定時間內沒有任何進入,即不會讀取新的資料,也沒有輸出資料,則認為該 task 處于 block 狀態,可能是臨時卡住,也許永遠會卡住,為了防止因為用戶程式永遠 block 不退出,則強制設定了一個超時時間(單位毫秒),默認是600000,值為 0 將禁用超時
9.Hive視窗函式不能大小寫混亂
max( ) over ( partition by prcid order by b.occurtime desc ) 不能大小寫混亂
10.hive客戶端日志
hive --verbos=true
hive --hiveconf hive.root.logger=DEBUG,console
11.~/.beeline/history && ~/.hivehistory在2.1版本下,會oom
導致客戶端執行命令時候直接卡住,解決方式洗掉或者移動備份這個檔案
吳邪,小三爺,混跡于后臺,大資料,人工智能領域的小菜鳥,
更多請關注

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/267319.html
標籤:其他
上一篇:與情預測股票
