hive执行报错:Both left and right aliases encountered in JOIN 'orderdate'

错误原因:两个表join的时候,不支持两个表的字段的 非相等 操作。

解决办法:
1、把不相等条件拿到where语句中

1
2
3
select ... from
class_order t1
left join class_order_refund t2 on t1.orderdate>t2.orderdate

可以改写成

1
2
3
4
select ... from
class_order t1
left join class_order_refund t2
where t1.orderdate>t2.orderdate

2、如果第一中方法不适用,可以在select字段中判断

1
2
3
4
5
6
7
select
...
if(t1.orderdate>t2.orderdate,0,1) as is_refund
...
from
class_order t1
left join class_order_refund t2 on t1.orderdate>t2.orderdate

JouyPub wechat
欢迎订阅「K叔区块链」 - 专注于区块链技术学习