在hive裡面可以通過嚴格模式防止使用者執行那些可能產生意想不到的不好的效果的查詢,從而保護hive的集群。
使用者可以通過 set hive.mapred.mode=strict 來設定嚴格模式,改成unstrict則為飛嚴格模式。 在嚴格模式下,使用者在執行如下query的時候會報錯。
1. 分割槽表的查詢沒有使用分割槽欄位來限制。
select*from mart_catering.dim_shopca_reduction_ss limit 1000;
得到的錯誤是
clidriver update main thread name to 4105daa5-e5a7-49d6-8e02-52c9184732f916/08/29 11:20:54 info clidriver: clidriver update main thread name to 4105daa5-e5a7-49d6-8e02-52c9184732f9
logging initialized using configuration in jar:file:/opt/meituan/versions/mthive-0.13-package/lib/hive-common-0.13.1.jar!/hive-log4j.properties
failed: semanticexception [error 10041]: no partition predicate found for alias 'dim_shopca_reduction_ss' table 'dim_shopca_reduction_ss'
query fails
2. 使用了笛卡爾積
當使用者寫**將表的別名寫錯的時候會引起笛卡爾積,例如
select*from
origindb.promotion__campaign c
join
origindb.promotion__campaignex ce
on c.id =
c.id
limit
1000
得到的錯誤資訊
clidriver update main thread name to 9a962abc-afea-470f-9738-dceda72ff1fd16/08/29 11:38:23 info clidriver: clidriver update main thread name to 9a962abc-afea-470f-9738-dceda72ff1fd
logging initialized using configuration in jar:file:/opt/meituan/versions/mthive-0.13-package/lib/hive-common-0.13.1.jar!/hive-log4j.properties
failed: semanticexception [error 10052]: in strict mode, cartesian product is not allowed. if you really want to perform the operation, set hive.mapred.mode=nonstrict
query fails
3. order by 的時候沒有使用limit
select*from
origindb.promotion__campaign
order
by id
得到的錯誤資訊
clidriver update main thread name to 5efafee6-1ce8-4985-9b98-c8f5ff88bccd16/08/29 11:40:45 info clidriver: clidriver update main thread name to 5efafee6-1ce8-4985-9b98-c8f5ff88bccd
logging initialized using configuration in jar:file:/opt/meituan/versions/mthive-0.13-package/lib/hive-common-0.13.1.jar!/hive-log4j.properties
failed: semanticexception 3:9 in strict mode, if order by is specified, limit must also be specified. error encountered near token 'id'
query fails
當使用的limit的時候錯誤消除。
hive 嚴格模式
hive提供了乙個嚴格模式,可以防止使用者執行那些可能產生意向不到的不好的效果的查詢。說通俗一點就是這種模式可以阻止某些查詢的執行。通過如下語句設定嚴格模式 hive set hive.mapred.mode strict hive select distinct planner id from f...
hive嚴格模式
hive嚴格模式 hive提供了乙個嚴格模式,可以防止使用者執行那些可能產生意想不到的不好的效果的查詢。即某些查詢在嚴格 模式下無法執行。1 帶有分割槽的表的查詢 如果在乙個分割槽表執行hive,除非where語句中包含分割槽字段過濾條件來顯示資料範圍,否則不允許執行。換句話說,就是使用者不允許掃瞄...
hive嚴格模式
說真的,這個模式在我做sql開發的歲月裡,從未用到過。用的都是動態分割槽非嚴格模式。我的好友東嶽同學在車上問我。確實問到了我 體現出了我基本功不紮實的情況。hive提供了乙個嚴格模式,可以防止使用者執行那些可能產生意向不到的不好的效果的查詢。說通俗一點就是這種模式可以阻止某些查詢的執行。通過如下語句...