-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Support correct output column names and struct field names when consuming/producing Substrait #10829
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
Merged
alamb
merged 5 commits into
apache:main
from
Blizzara:avo/substrait-consumer-fix-output-column-names
Jun 11, 2024
Merged
Support correct output column names and struct field names when consuming/producing Substrait #10829
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bbd058f
produce flattened list of names including inner struct fields
Blizzara 79d0851
add a (failing) test
Blizzara 55b0428
rename output columns (incl. inner struct fields) according to the gi…
Blizzara 6c1bb88
fix a test
Blizzara d0f6a8e
add column names project to the new TPC-H test and fix case
Blizzara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,11 @@ async fn wildcard_select() -> Result<()> { | |
roundtrip("SELECT * FROM data").await | ||
} | ||
|
||
#[tokio::test] | ||
async fn select_with_alias() -> Result<()> { | ||
roundtrip("SELECT a AS aliased_a FROM data").await | ||
} | ||
|
||
#[tokio::test] | ||
async fn select_with_filter() -> Result<()> { | ||
roundtrip("SELECT * FROM data WHERE a > 1").await | ||
|
@@ -367,9 +372,9 @@ async fn implicit_cast() -> Result<()> { | |
async fn aggregate_case() -> Result<()> { | ||
assert_expected_plan( | ||
"SELECT sum(CASE WHEN a > 0 THEN 1 ELSE NULL END) FROM data", | ||
"Aggregate: groupBy=[[]], aggr=[[sum(CASE WHEN data.a > Int64(0) THEN Int64(1) ELSE Int64(NULL) END)]]\ | ||
"Aggregate: groupBy=[[]], aggr=[[sum(CASE WHEN data.a > Int64(0) THEN Int64(1) ELSE Int64(NULL) END) AS sum(CASE WHEN data.a > Int64(0) THEN Int64(1) ELSE NULL END)]]\ | ||
\n TableScan: data projection=[a]", | ||
false // NULL vs Int64(NULL) | ||
true | ||
) | ||
.await | ||
} | ||
|
@@ -589,32 +594,23 @@ async fn roundtrip_union_all() -> Result<()> { | |
|
||
#[tokio::test] | ||
async fn simple_intersect() -> Result<()> { | ||
// Substrait treats both COUNT(*) and COUNT(1) the same | ||
assert_expected_plan( | ||
"SELECT COUNT(*) FROM (SELECT data.a FROM data INTERSECT SELECT data2.a FROM data2);", | ||
"Aggregate: groupBy=[[]], aggr=[[COUNT(Int64(1))]]\ | ||
"Aggregate: groupBy=[[]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]\ | ||
\n Projection: \ | ||
\n LeftSemi Join: data.a = data2.a\ | ||
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\ | ||
\n TableScan: data projection=[a]\ | ||
\n TableScan: data2 projection=[a]", | ||
false // COUNT(*) vs COUNT(Int64(1)) | ||
true | ||
) | ||
.await | ||
} | ||
|
||
#[tokio::test] | ||
async fn simple_intersect_table_reuse() -> Result<()> { | ||
assert_expected_plan( | ||
"SELECT COUNT(*) FROM (SELECT data.a FROM data INTERSECT SELECT data.a FROM data);", | ||
"Aggregate: groupBy=[[]], aggr=[[COUNT(Int64(1))]]\ | ||
\n Projection: \ | ||
\n LeftSemi Join: data.a = data.a\ | ||
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\ | ||
\n TableScan: data projection=[a]\ | ||
\n TableScan: data projection=[a]", | ||
false // COUNT(*) vs COUNT(Int64(1)) | ||
) | ||
.await | ||
roundtrip("SELECT COUNT(1) FROM (SELECT data.a FROM data INTERSECT SELECT data.a FROM data);").await | ||
} | ||
|
||
#[tokio::test] | ||
|
@@ -694,20 +690,14 @@ async fn all_type_literal() -> Result<()> { | |
|
||
#[tokio::test] | ||
async fn roundtrip_literal_list() -> Result<()> { | ||
assert_expected_plan( | ||
"SELECT [[1,2,3], [], NULL, [NULL]] FROM data", | ||
"Projection: List([[1, 2, 3], [], , []])\ | ||
\n TableScan: data projection=[]", | ||
false, // "List(..)" vs "make_array(..)" | ||
) | ||
.await | ||
roundtrip("SELECT [[1,2,3], [], NULL, [NULL]] FROM data").await | ||
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 verified that |
||
} | ||
|
||
#[tokio::test] | ||
async fn roundtrip_literal_struct() -> Result<()> { | ||
assert_expected_plan( | ||
"SELECT STRUCT(1, true, CAST(NULL AS STRING)) FROM data", | ||
"Projection: Struct({c0:1,c1:true,c2:})\ | ||
"Projection: Struct({c0:1,c1:true,c2:}) AS struct(Int64(1),Boolean(true),NULL)\ | ||
\n TableScan: data projection=[]", | ||
false, // "Struct(..)" vs "struct(..)" | ||
) | ||
|
@@ -980,12 +970,13 @@ async fn assert_expected_plan( | |
|
||
println!("{proto:?}"); | ||
|
||
let plan2str = format!("{plan2:?}"); | ||
assert_eq!(expected_plan_str, &plan2str); | ||
|
||
if assert_schema { | ||
assert_eq!(plan.schema(), plan2.schema()); | ||
} | ||
|
||
let plan2str = format!("{plan2:?}"); | ||
assert_eq!(expected_plan_str, &plan2str); | ||
|
||
Ok(()) | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎉