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

Initial support LogicalPlan to SQL String #9596

Merged
merged 1 commit into from
Mar 13, 2024
Merged

Conversation

backkem
Copy link
Contributor

@backkem backkem commented Mar 13, 2024

Relates to #8661

This is an initial attempt at porting over the LogicalPlan Unparser as described in the tracking ticket.

I took a similar approach to #9517 but moved the tests to sql::tests to make use of the MockContextProvider. I also took a stab at turning the tests into the roundtrip style (SQL -> Expr/Plan -> SQL) as discussed in the Expr PR.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @backkem -- this looks (really) nice to me. It is great to establish the pattern and then as people need more features they can contribute more to it.

Note I believe this will logically conflict somewhat with @devinjdangelo 's addition of a unparser feature flag in #9578

datafusion/sql/src/unparser/ast.rs Outdated Show resolved Hide resolved
datafusion/sql/src/unparser/plan.rs Outdated Show resolved Hide resolved
datafusion/sql/src/unparser/plan.rs Outdated Show resolved Hide resolved
@@ -4487,6 +4490,87 @@ impl TableSource for EmptyTable {
}
}

#[test]
fn roundtrip_expr() {
let tests: Vec<(TableReference, &str, &str)> = vec![
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @devinjdangelo -- maybe we can consolidate the round trip expr tests from #9578 here too

@alamb alamb changed the title feat: support LogicalPlan to SQL String Initial support LogicalPlan to SQL String Mar 13, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since #9578 is potentially conflicting and this one is larger, merging this PR in first

@alamb alamb merged commit 51d9441 into apache:main Mar 13, 2024
24 checks passed
@backkem backkem deleted the plan-to-sql branch March 13, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants