-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Substrait: Fix incorrect join key fields (indices) when same table is being used more than once #6135
Substrait: Fix incorrect join key fields (indices) when same table is being used more than once #6135
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,6 +412,30 @@ mod tests { | |
roundtrip("SELECT a,b,c,d,e FROM datafusion.public.data;").await | ||
} | ||
|
||
#[tokio::test] | ||
async fn roundtrip_inner_join_table_reuse_zero_index() -> Result<()> { | ||
assert_expected_plan( | ||
"SELECT d1.b, d2.c FROM data d1 JOIN data d2 ON d1.a = d2.a", | ||
"Projection: data.b, data.c\ | ||
\n Inner Join: data.a = data.a\ | ||
\n TableScan: data projection=[a, b]\ | ||
\n TableScan: data projection=[a, c]", | ||
Comment on lines
+418
to
+422
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried this case against the main branch and it can pass. I guess this is not the original query that causes the error? BTW, if two tables have the same name, does it means they are the same table? (for this case, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I recall correctly, this would have failed in the earlier version of DF where However, even if this error does not get thrown, and the test passes, it also does not mean that the produced Substrait plan is correct. If we join the same table to itself, the |
||
) | ||
.await | ||
} | ||
|
||
#[tokio::test] | ||
async fn roundtrip_inner_join_table_reuse_non_zero_index() -> Result<()> { | ||
assert_expected_plan( | ||
"SELECT d1.b, d2.c FROM data d1 JOIN data d2 ON d1.b = d2.b", | ||
"Projection: data.b, data.c\ | ||
\n Inner Join: data.b = data.b\ | ||
\n TableScan: data projection=[b]\ | ||
\n TableScan: data projection=[b, c]", | ||
) | ||
.await | ||
} | ||
|
||
/// Construct a plan that contains several literals of types that are currently supported. | ||
/// This case ignores: | ||
/// - Date64, for this literal is not supported | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍