背景:hive 中使用 left join 时,是否可以在 on 条件中中加入限制条件。
结论:不可以,但是在inner join 中是可以的。
create table test.test_no_part (id int ,name string);
insert overwrite table test.test_no_part VALUES (1,'a'),(2,'b'),(3,'c');
create table test.test_no_part_b (id int ,name string);
insert overwrite table test.test_no_part_b VALUES (1,'a'),(2,'b'),(4,'d');
SELECT
t.*,t1.*
from
test.test_no_part t
left join
test.test_no_part_b t1
on t.id =t1.id
;

?当 on 中加入限制条件时,结果出乎意料。
SELECT
t.*,t1.*
from
test.test_no_part t
left join
test.test_no_part_b t1
on t.id =t1.id and t.id=1
;
?
|