hive sql报错FAILED: SemanticException Line 0:-1 Both left and right aliases encountered in JOIN

在hql脚本时报错FAILED: SemanticException Line 0:-1 Both left and right aliases encountered in JOIN ,由于连接条件导致hql不能执行,网上查到了解决办法https://stackoverflow.com/questions/39852325/both-left-and-right-aliases-encountered-in-hive-join-without-any-inequality-cla

这个问题的解决是将连接条件放入where条件中;

select * from a left join b on a.x = b.x and a.y = b.y

报错原因是第二个连接条件,改为

select * from a left join b on a.x = b.x
where a.y = b.y

hql可以正常执行但是仔细看一下这个替代hql会发现其查询结果会有细微的差别,由于是left join 左边表的数据应该是全的,但是第二种方式会导致右边有y左边没有y的结果被过滤掉;

解决办法:在where条件中添加条件补救

select * from a left join b on a.x = b.x
where a.y= b.y or b.y is null

 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值