大数据全系列 教程
1869个小节阅读:465.4k
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
参数设置
xxxxxxxxxx
hive> set hive.mapred.mode;
hive.mapred.mode is undefined #也任务是非严格模式
hive> set hive.mapred.mode=strict;#严格模式
hive> set hive.mapred.mode=nostrict;#非严格模式
查询限制:
1、对于分区表,必须添加where对于分区字段的条件过滤;
xxxxxxxxxx
#非严格模式下,不指定分区条件也可以查找
hive> select * from person5;
OK
person5.id person5.name person5.likes person5.address person5.age
1 小明1 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 10
2 小明2 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 10
3 小明3 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 10
4 小明4 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 10
5 小明5 ["lol","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 10
6 小明6 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 10
7 小明7 ["lol","book"] {"beijing":"xisanqi","shanghai":"pudong"} 10
8 小明8 ["lol","book"] {"beijing":"xisanqi","shanghai":"pudong"} 10
9 小明9 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 10
1 小明1 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 20
2 小明2 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 20
设置为严格模式后:
xxxxxxxxxx
hive> set hive.mapred.mode=strict;
# 在严格模式下,对分区表查询不指定分区的过滤条件,不允许查询。
hive> select * from person5;
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 "person5" Table "person5"
#在严格模式下,指定了分区过滤条件后,可以正常的查询
hive> select * from person5 where age=20;
OK
person5.id person5.name person5.likes person5.address person5.age
1 小明1 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 20
2 小明2 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 20
3 小明3 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 20
4 小明4 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 20
5 小明5 ["lol","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 20
6 小明6 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 20
7 小明7 ["lol","book"] {"beijing":"xisanqi","shanghai":"pudong"} 20
8 小明8 ["lol","book"] {"beijing":"xisanqi","shanghai":"pudong"} 20
9 小明9 ["lol","book","movie"] {"beijing":"xisanqi","shanghai":"pudong"} 20
Time taken: 3.077 seconds, Fetched: 9 row(s)
2、order by语句必须包含limit输出限制;
xxxxxxxxxx
hive> select * from person order by id desc;
FAILED: SemanticException 1:30 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 'id'
hive> select * from person order by id desc limit 3;
Query ID = root_20211122144621_1f94c13b-4669-427b-95c9-6cfbee77ebf0
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks determined at compile time: 1
......
使用order by语句必须使用limit语句。
3、限制执行笛卡尔积的查询。
(1) 严格模式下避免出现笛卡尔积。
xxxxxxxxxx
hive> select * from emp e,dept d;
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.