-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(substrait): fix regressed edge case in renaming inner struct fields #15634
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
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 |
---|---|---|
|
@@ -1061,7 +1061,7 @@ async fn roundtrip_literal_list() -> Result<()> { | |
async fn roundtrip_literal_struct() -> Result<()> { | ||
let plan = generate_plan_from_sql( | ||
"SELECT STRUCT(1, true, CAST(NULL AS STRING)) FROM data", | ||
false, | ||
true, | ||
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. unrelated, but it was passing with true so why not have that |
||
true, | ||
) | ||
.await?; | ||
|
@@ -1076,6 +1076,46 @@ async fn roundtrip_literal_struct() -> Result<()> { | |
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn roundtrip_literal_named_struct() -> Result<()> { | ||
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. this uses a named_struct() func so it wasn't hitting the bug, but I kept it as an addition still |
||
let plan = generate_plan_from_sql( | ||
"SELECT STRUCT(1 as int_field, true as boolean_field, CAST(NULL AS STRING) as string_field) FROM data", | ||
true, | ||
true, | ||
) | ||
.await?; | ||
|
||
assert_snapshot!( | ||
plan, | ||
@r#" | ||
Projection: Struct({int_field:1,boolean_field:true,string_field:}) AS named_struct(Utf8("int_field"),Int64(1),Utf8("boolean_field"),Boolean(true),Utf8("string_field"),NULL) | ||
TableScan: data projection=[] | ||
"# | ||
); | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn roundtrip_literal_renamed_struct() -> Result<()> { | ||
// This test aims to hit a case where the struct column itself has the expected name, but its | ||
// inner field needs to be renamed. | ||
let plan = generate_plan_from_sql( | ||
"SELECT CAST((STRUCT(1)) AS Struct<\"int_field\"Int>) AS 'Struct({c0:1})' FROM data", | ||
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 don't understand how this query is converting String --> StringView (this seems like a good test in my opinion) 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. Ah, there's no String -> StringView in this test. This is just the test the regression that happened in Substrait consumer, where we were no longer renaming the inner fields, as the "is the schema the same" check passed too easily. The String -> StringView is tested by the slt tests added in #15239 |
||
true, | ||
true, | ||
) | ||
.await?; | ||
|
||
assert_snapshot!( | ||
plan, | ||
@r#" | ||
Projection: Struct({int_field:1}) AS Struct({c0:1}) | ||
TableScan: data projection=[] | ||
"# | ||
); | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn roundtrip_values() -> Result<()> { | ||
// TODO: would be nice to have a struct inside the LargeList, but arrow_cast doesn't support that currently | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
Thank you @Blizzara for fix, this new relax looks good to me, and if we want more relax type, we can add later.