-
Notifications
You must be signed in to change notification settings - Fork 2k
Only unnest source for EmptyRelation
#15159
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 1 commit
fb1f679
28f5301
1cb70d7
ef4a79d
d9218c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
EmptyRelation
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -377,8 +377,17 @@ impl Unparser<'_> { | |
| }; | ||
| if self.dialect.unnest_as_table_factor() && unnest_input_type.is_some() { | ||
| if let LogicalPlan::Unnest(unnest) = &p.input.as_ref() { | ||
| return self | ||
| .unnest_to_table_factor_sql(unnest, query, select, relation); | ||
| if let LogicalPlan::Projection(projection) = unnest.input.as_ref() | ||
| { | ||
| if matches!( | ||
| projection.input.as_ref(), | ||
| LogicalPlan::EmptyRelation(_) | ||
|
||
| ) { | ||
| return self.unnest_to_table_factor_sql( | ||
| unnest, query, select, relation, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
Collaborator
Author
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. Had to remove this new test because now (even in main) it produces
Contributor
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 this comment -- doesn't this PR add a new test?
Collaborator
Author
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. Sorry -- before I added one more test, but then I have to remove it due to ef4a79d - I think we can discuss in that issue and work on it further |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -639,6 +639,24 @@ fn roundtrip_statement_with_dialect() -> Result<()> { | |
| parser_dialect: Box::new(GenericDialect {}), | ||
| unparser_dialect: Box::new(CustomDialectBuilder::default().with_unnest_as_table_factor(true).build()), | ||
| }, | ||
| TestStatementWithDialect { | ||
| sql: "SELECT unnest([1, 2, 3, 4]) from unnest([1, 2, 3]);", | ||
| expected: r#"SELECT UNNEST([1, 2, 3, 4]) AS UNNEST(make_array(Int64(1),Int64(2),Int64(3),Int64(4))) FROM UNNEST([1, 2, 3])"#, | ||
| parser_dialect: Box::new(GenericDialect {}), | ||
| unparser_dialect: Box::new(CustomDialectBuilder::default().with_unnest_as_table_factor(true).build()), | ||
| }, | ||
| TestStatementWithDialect { | ||
| sql: "SELECT unnest([1, 2, 3, 4]) from unnest([1, 2, 3]);", | ||
| expected: r#"SELECT UNNEST([1, 2, 3, 4]) AS UNNEST(make_array(Int64(1),Int64(2),Int64(3),Int64(4))) FROM UNNEST([1, 2, 3])"#, | ||
| parser_dialect: Box::new(GenericDialect {}), | ||
| unparser_dialect: Box::new(CustomDialectBuilder::default().with_unnest_as_table_factor(true).build()), | ||
| }, | ||
|
Comment on lines
+636
to
+647
Contributor
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. They look like the same. 🤔 I think we can remove one of them. |
||
| TestStatementWithDialect { | ||
| sql: "select * from (select [1, 2, 3] as c), unnest(c);", | ||
| expected: r#"SELECT * FROM (SELECT [1, 2, 3] AS c) CROSS JOIN UNNEST(c)"#, | ||
| parser_dialect: Box::new(GenericDialect {}), | ||
| unparser_dialect: Box::new(CustomDialectBuilder::default().with_unnest_as_table_factor(true).build()), | ||
| }, | ||
| TestStatementWithDialect { | ||
| sql: "SELECT * FROM unnest_table u, UNNEST(u.array_col)", | ||
| expected: r#"SELECT * FROM unnest_table AS u CROSS JOIN LATERAL (SELECT UNNEST(u.array_col) AS "UNNEST(outer_ref(u.array_col))")"#, | ||
|
|
||
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.
This feels like something that is a limitation of
unnest_to_table_factor_sql-- would it make sense to put the check in there so the check and the code with the assumption are in the same place?