【Hive】join时的小技巧

有时候join或者where两表时会报错:

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.

我们必须在代码前加上下面这段才能通过:

set hive.strict.checks.cartesian.product=flase;
set hive.mapred.mode=nonstrict;	

出现这种原因是因为笛卡尔积,为了防止这种情况可以让两表额外补上一列以便join上,select 1 as rn,...,两表通过rn作为join key

猜你喜欢

转载自blog.csdn.net/weixin_43955488/article/details/126246397