(详细)解决hive报错FAILED: SemanticException Cartesian products are disabled for safety的问题

在使用hive-2.3.3执行TPC-H benchmark时,遇到hive报错。而且这个错误不是以Java异常栈的形式跑出的,很可能被忽略:

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.

查阅网上资料,发现有两种方法。

方式一:通过hive shell 模式设置相关变量
通过hive 命令开启hive shell 模式,输入以下命令进行设置:

hive> set hive.mapred.mode;   # 首先查看hive.mapred.mode
hive.mapred.mode=strict
hive> set hive.mapred.mode=nonstrict;   # 设置hive.mapred.mode为nonstrict
hive> set hive.mapred.mode;   # 查看hive.mapred.mode是否设置成功
hive.mapred.mode=nonstrict
hive> set hive.strict.checks.cartesian.product;   # 首先查看hive.strict.checks.cartesian.product
hive.strict.checks.cartesian.product=true
hive> set hive.strict.checks.cartesian.product=false;   # 设置hive.strict.checks.cartesian.product为false
hive> set hive.strict.checks.cartesian.product;    # 查看hive.strict.checks.cartesian.product是否设置成功
hive.strict.checks.cartesian.product=false

方式二:在hive-site.xml中设置相关变量
hive-site.xml文件中,加入新的设置:

<property> 
	  <name>hive.mapred.mode</name> 
	  <value>nonstrict</value> 
	  <description>The mode in which the hive operations are being performed. In strict mode, some risky queries are not allowed to run</description> 
</property>
<property> 
        <name>hive.strict.checks.cartesian.product</name> 
        <value>false</value>
</property>

由于都是处于尝试修改错误,所以都不知道自己究竟是使用哪种方法解决了这个错误的。下次再配置hive,建议一开始就在hive-site.xml中添加上面的内容。如果还会报错,再尝试方法一!

参考链接:
hive参数hive.mapred.mode分析
一例 Hive join 优化实战----8和9两点
hive strict模式-----重点参考
How allow hive.mapred.mode=nonstrict?
hive 非等值连接, 设置hive为nonstrict模式
STRICT MODE VS NON-STRICT MODE IN HIVE OR STATIC PARTITION VS DYNAMIC PARTITION IN HIVE?

  • 7
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值