Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove logical cross join in planning #12985

Merged
merged 23 commits into from
Oct 18, 2024
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
Dandandan committed Oct 17, 2024
commit 69416bafd3bc3f2e32f8eccf5d2477910b4e1411
30 changes: 15 additions & 15 deletions datafusion/sql/tests/sql_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ fn natural_right_join() {
fn natural_join_no_common_becomes_cross_join() {
let sql = "SELECT * FROM person a NATURAL JOIN lineitem b";
let expected = "Projection: *\
\n CrossJoin:\
\n Cross Join: \
\n SubqueryAlias: a\
\n TableScan: person\
\n SubqueryAlias: b\
Expand Down Expand Up @@ -2742,8 +2742,8 @@ fn cross_join_not_to_inner_join() {
"select person.id from person, orders, lineitem where person.id = person.age;";
let expected = "Projection: person.id\
\n Filter: person.id = person.age\
\n CrossJoin:\
\n CrossJoin:\
\n Cross Join: \
\n Cross Join: \
\n TableScan: person\
\n TableScan: orders\
\n TableScan: lineitem";
Expand Down Expand Up @@ -2840,11 +2840,11 @@ fn exists_subquery_schema_outer_schema_overlap() {
\n Subquery:\
\n Projection: person.first_name\
\n Filter: person.id = p2.id AND person.last_name = outer_ref(p.last_name) AND person.state = outer_ref(p.state)\
\n CrossJoin:\
\n Cross Join: \
\n TableScan: person\
\n SubqueryAlias: p2\
\n TableScan: person\
\n CrossJoin:\
\n Cross Join: \
\n TableScan: person\
\n SubqueryAlias: p\
\n TableScan: person";
Expand Down Expand Up @@ -2932,10 +2932,10 @@ fn scalar_subquery_reference_outer_field() {
\n Projection: count(*)\
\n Aggregate: groupBy=[[]], aggr=[[count(*)]]\
\n Filter: outer_ref(j2.j2_id) = j1.j1_id AND j1.j1_id = j3.j3_id\
\n CrossJoin:\
\n Cross Join: \
\n TableScan: j1\
\n TableScan: j3\
\n CrossJoin:\
\n Cross Join: \
\n TableScan: j1\
\n TableScan: j2";

Expand Down Expand Up @@ -3121,7 +3121,7 @@ fn join_on_complex_condition() {
fn lateral_constant() {
let sql = "SELECT * FROM j1, LATERAL (SELECT 1) AS j2";
let expected = "Projection: *\
\n CrossJoin:\
\n Cross Join: \
\n TableScan: j1\
\n SubqueryAlias: j2\
\n Subquery:\
Expand All @@ -3136,7 +3136,7 @@ fn lateral_comma_join() {
j1, \
LATERAL (SELECT * FROM j2 WHERE j1_id < j2_id) AS j2";
let expected = "Projection: j1.j1_string, j2.j2_string\
\n CrossJoin:\
\n Cross Join: \
\n TableScan: j1\
\n SubqueryAlias: j2\
\n Subquery:\
Expand All @@ -3152,7 +3152,7 @@ fn lateral_comma_join_referencing_join_rhs() {
\n j1 JOIN (j2 JOIN j3 ON(j2_id = j3_id - 2)) ON(j1_id = j2_id),\
\n LATERAL (SELECT * FROM j3 WHERE j3_string = j2_string) as j4;";
let expected = "Projection: *\
\n CrossJoin:\
\n Cross Join:\
\n Inner Join: Filter: j1.j1_id = j2.j2_id\
\n TableScan: j1\
\n Inner Join: Filter: j2.j2_id = j3.j3_id - Int64(2)\
Expand All @@ -3176,12 +3176,12 @@ fn lateral_comma_join_with_shadowing() {
) as j2\
) as j2;";
let expected = "Projection: *\
\n CrossJoin:\
\n Cross Join:\
\n TableScan: j1\
\n SubqueryAlias: j2\
\n Subquery:\
\n Projection: *\
\n CrossJoin:\
\n Cross Join:\
\n TableScan: j1\
\n SubqueryAlias: j2\
\n Subquery:\
Expand Down Expand Up @@ -3213,7 +3213,7 @@ fn lateral_nested_left_join() {
j1, \
(j2 LEFT JOIN LATERAL (SELECT * FROM j3 WHERE j1_id + j2_id = j3_id) AS j3 ON(true))";
let expected = "Projection: *\
\n CrossJoin:\
\n Cross Join: \
\n TableScan: j1\
\n Left Join: Filter: Boolean(true)\
\n TableScan: j2\
Expand Down Expand Up @@ -4279,7 +4279,7 @@ fn test_table_alias() {

let expected = "Projection: *\
\n SubqueryAlias: f\
\n CrossJoin:\
\n Cross Join: \
\n SubqueryAlias: t1\
\n Projection: person.id\
\n TableScan: person\
Expand All @@ -4297,7 +4297,7 @@ fn test_table_alias() {
let expected = "Projection: *\
\n SubqueryAlias: f\
\n Projection: t1.id AS c1, t2.age AS c2\
\n CrossJoin:\
\n Cross Join: \
\n SubqueryAlias: t1\
\n Projection: person.id\
\n TableScan: person\
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/cte.slt
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ logical_plan
03)----Projection: Int64(1) AS val
04)------EmptyRelation
05)----Projection: Int64(2) AS val
06)------CrossJoin:
06)------Cross Join:
07)--------Filter: recursive_cte.val < Int64(2)
08)----------TableScan: recursive_cte
09)--------SubqueryAlias: sub_cte
Expand Down
Loading