第十章 Hive调优 【严格模式】
1. 严格模式
1. 什么是严格模式
hive对sql语法的一些安全性的限制
2. 分区表查询时必须指定分区
-- 开启限制(默认为 false)
set hive.strict.checks.no.partition.filter=true;
-- 测试
-- 测试
create table `partab` (
`occur_date` string comment '日期' )
comment 'tab' PARTITIONED BY (dt string)
row format delimited fields terminated by '\t' lines terminated by '\n' stored as orc;
set hive.strict.checks.no.partition.filter=true;
select * from partab limit 111;
FAILED: SemanticException [Error 10056]:
Queries against partitioned tables without a partition filter are disabled for safety reasons.
If you know what you are doing, please set hive.strict.checks.no.partition.
filter to false and make sure that hive.mapred.mode is not set to 'strict' to proceed.
Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features.
No partition predicate for Alias "partab" Table "partab"
select * from partab where dt='11' limit 111;
Time taken: 0.77 seconds
3. order by必须指定limit
-- 开启限制(默认为false)
set hive.strict.checks.orderby.no.limit=true;
说明 : order by 为全局排序,所有数据只有一个reduceTask来处理,防止单个reduce运行时间过长,而导致任务阻塞
-- 测试
-- 测试
set hive.strict.checks.orderby.no.limit=true;
select * from arraytab order by name;
FAILED: SemanticException 1:36
Order by-s without limit are disabled for safety reasons.
If you know what you are doing, please set hive.strict.checks.orderby.no.limit to false
and make sure that hive.mapred.mode is not set to 'strict' to proceed.
Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features..
Error encountered near token 'name'
4. 限制 笛卡尔积
-- 开启限制(默认为false)
set hive.strict.checks.cartesian.product=true;
说明 : 出发笛卡尔积时,join操作会在一个reduceTask中执行
-- 测试
-- 测试
set hive.strict.checks.cartesian.product=true;
select t1.*,t2.*
from arraytab as t1
inner join arraytab as t2;
FAILED: SemanticException Cartesian products are disabled for safety reasons.
If you know what you are doing, please set hive.strict.checks.cartesian.product to false
and make sure that hive.mapred.mode is not set to 'strict' to proceed.
Note that you may get errors or incorrect results
if you make a mistake while using some of the unsafe features.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下