前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Hive 编程入门 之 Join 的失效

Hive 编程入门 之 Join 的失效

作者头像
Lenis
发布2019-12-25 12:56:27
2.6K0
发布2019-12-25 12:56:27
举报
文章被收录于专栏:有关SQL有关SQL

环境:

代码语言:javascript
复制
Hive: 2.7.7
Oracle SQL Developer
Cloudera JDBC Driver

案例 - 1 : 非全等 Join 失效

代码语言:javascript
复制
select a.*, b.* 
from default.employee a 
inner join default.employee b on a.salary < b.salary

异常:

代码语言:javascript
复制
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 的操作。

代码语言:javascript
复制
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

最终非全等 Join 执行也顺利通过:


本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-11-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 有关SQL 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
大数据
全栈大数据产品,面向海量数据场景,帮助您 “智理无数,心中有数”!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档