diff --git a/dbms/tests/queries/0_stateless/00674_join_on_syntax.reference b/dbms/tests/queries/0_stateless/00674_join_on_syntax.reference index 7a41a90c03f..ae0944580e5 100644 --- a/dbms/tests/queries/0_stateless/00674_join_on_syntax.reference +++ b/dbms/tests/queries/0_stateless/00674_join_on_syntax.reference @@ -51,3 +51,23 @@ duplicate column names {"a1":1,"copy.a1":2} {"a1":1,"copy.a1":2} {"a1":1,"copy.a1":2} +subquery +1 +1 +1 2 +1 2 2 3 +1 2 +subquery expression +2 +1 2 2 3 +1 2 2 +subquery column alias +1 2 2 3 +1 2 2 3 +1 2 2 3 +subquery alias +1 2 2 3 +1 2 2 3 +1 2 2 3 +1 2 2 3 +{"a1":1,"s.a1":2} diff --git a/dbms/tests/queries/0_stateless/00674_join_on_syntax.sql b/dbms/tests/queries/0_stateless/00674_join_on_syntax.sql index 7fb60e64d04..06d930d8c6d 100644 --- a/dbms/tests/queries/0_stateless/00674_join_on_syntax.sql +++ b/dbms/tests/queries/0_stateless/00674_join_on_syntax.sql @@ -82,3 +82,26 @@ select a1, copy.a1 from test.tab1 any left join test.tab1_copy copy on tab1.b1 + select a1, tab1_copy.a1 from test.tab1 any left join test.tab1_copy copy on tab1.b1 + 3 = b1 + 2 FORMAT JSONEachRow; select a1, test.tab1_copy.a1 from test.tab1 any left join test.tab1_copy copy on tab1.b1 + 3 = b1 + 2 FORMAT JSONEachRow; +select 'subquery'; +select a1 from test.tab1 any left join (select * from test.tab2) on b1 = a2; +select a1 from test.tab1 any left join (select a2 from test.tab2) on b1 = a2; +select a1, b1 from test.tab1 any left join (select * from test.tab2) on b1 = a2; +select a1, b1, a2, b2 from test.tab1 any left join (select * from test.tab2) on b1 = a2; +select a1, a2 from test.tab1 any left join (select a2 from test.tab2) on b1 = a2; + +select 'subquery expression'; +select b1 from test.tab1 any left join (select * from test.tab2) on toInt32(a1 + 1) = a2; +select a1, b1, a2, b2 from test.tab1 any left join (select * from test.tab2) on b1 + 1 = a2 + 1; +select a1, b1, a2 from test.tab1 any left join (select * from test.tab2) on b1 + 1 = a2 + 1; + +select 'subquery column alias'; +select a1, b1, a2, b2 from test.tab1 any left join (select *, a2 as z from test.tab2) on b1 + 1 = z + 1; +select a1, b1, a2, b2 from test.tab1 any left join (select *, a2 + 1 as z from test.tab2) on b1 + 1 = z; +select a1, b1, a2, b2 from test.tab1 any left join (select *, a2 + 1 as z from test.tab2) on b1 + 2 = z + 1 format TSV; + +select 'subquery alias'; +select a1, a2, b1, b2 from test.tab1 first any left join (select * from test.tab2) second on first.b1 = second.a2; +select a1, a2, b1, b2 from test.tab1 first any left join (select *, a2 as z from test.tab2) second on first.b1 = second.z; +select a1, a2, b1, b2 from test.tab1 first any left join (select *, a2 + 1 as z from test.tab2) second on first.b1 + 1 = second.z; +select tab1.a1, a2, test.tab1.b1, second.b2 from test.tab1 first any left join (select * from test.tab2) second on first.b1 = second.a2; +select a1, s.a1 from test.tab1 any left join (select * from test.tab1_copy) s on tab1.b1 + 3 = b1 + 2 FORMAT JSONEachRow;