1. 程式人生 > >hive嚴格模式:No partition predicate found for Alias

hive嚴格模式:No partition predicate found for Alias

在hive提數時出現瞭如下報錯:Error while compiling statement: FAILED: SemanticException [Error 10041]: No partition predicate found for Alias。這是因為hive提供了一個嚴格模式,可以防止使用者執行那些可能產生意想不到的不好效果的查詢。即某些查詢在嚴格模式下無法執行。

sample 1:在一個分割槽表執行hive,除非where語句中包含分割槽欄位過濾條件來顯示資料範圍,否則不允許執行。換句話說, 就是使用者不允許掃描所有的分割槽。進行這個限制的原因是,通常分割槽表都擁有非常大的資料集,而且資料增加迅速。

如果沒有進行分割槽限制的查詢可能會消耗令人不可接受的巨大資源來處理這個表。

如下語句報錯:

select t4.id,t4.order_type from all_order.wm_order_too t4

將如上語句加上where限制條件後恢復正常:

select t4.id,t4.order_type from all_order.wm_order_too t4  where t4.dt between '20180601'  and  '20180630'

sample 2:帶有orderby的查詢   對於使用了orderby的查詢,要求必須有limit語句。因為orderby為了執行排序過程會講所有的結果分發到同一個reducer中   進行處理,強烈要求使用者增加這個limit語句可以防止reducer額外執行很長一段時間:   SELECT * FROM fracture_ins WHERE hit_date>2012 ORDER BY planner_id;   FAILED: Error in semantic analysis: line 1:56 In strict mode,   limit must be specified if ORDER BY is present planner_id

 只需要增加limit語句就可以解決這個問題: SELECT * FROM fracture_ins WHERE hit_date>2012 ORDER BY planner_id  LIMIT 100000;