Hive 编程专题九 : SQL Join 的那点坑

环境:

Hive: 2.7.7
Oracle SQL Developer
Cloudera JDBC Driver

案例 - 1 : 非全等 Join 失效

select a.*, b.* 
from default.employee a 
inner join default.employee b on a.salary < b.salary

异常:

SQL 错误: [Cloudera][HiveJDBCDriver](500051) ERROR processing query/statement. Error Code: 40000, SQL state: TStatus(statusCode:ERROR_STATUS, infoMessages:[*org.apache.hive.service.cli.HiveSQLException:Error while compiling statement: FAILED: SemanticException Cartesian products are disabled for safety reasons. If you know what you are doing, please sethive.strict.checks.cartesian.product to false and that hive.mapred.mode is not set to 'strict' to proceed. Note that if you may get errors or incorrect results if you make a mistake while using some of the unsafe features.:17:16,
...(省去万字)
SemanticException Cartesian products are disabled for safety reasons. If you know what you are doing, please sethive.strict.checks.cartesian.product to false and that hive.mapred.mode is not set to 'strict' to proceed. Note that if you may get errors or incorrect results if you make a mistake while using some of the unsafe features.), Query: select a.*, b.* 
from default.employee a 
inner join default.employee b on a.salary < b.salary.

为了保障整个集群的稳定性,类似非全等的 Join 是默认禁止的,原因在异常代码中给出了:

FAILED: SemanticException Cartesian products are disabled for safety reasons

这样就可以避免因为大数据的 Join 导致网络瘫痪。

如果清晰的知道,非全等 Join 不会造成影响,那么可以修改这些配置来启动非全等 join 的操作。

set hive.strict.checks.cartesian.product=false
set hive.mapred.mode=nonstrict

select a.*, b.* 
from default.employee a 
inner join default.employee b on a.salary < b.salary


结果是这样:

image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dbLenis

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值