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

refactor: move PREPARE/EXECUTE into LogicalPlan::Statement #13311

Merged
merged 4 commits into from
Nov 9, 2024

Conversation

jonahgao
Copy link
Member

@jonahgao jonahgao commented Nov 8, 2024

Which issue does this PR close?

See #13242 (comment)

Rationale for this change

Move LogicalPlan::Prepare and LogicalPlan::Execute into LogicalPlan::Statement.

They are more suitable for being implemented as statements. This can also reduce the variants of LogicalPlan.

What changes are included in this PR?

  • Move PREPARE/EXECUTE into LogicalPlan::Statement
  • Statements share a global empty schema instead of each holding a dummy schema, which eliminates the need for manual implementations of PartialOrd

Are these changes tested?

Yes. By existing tests.

Are there any user-facing changes?

Yes

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions optimizer Optimizer rules core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) proto Related to proto crate labels Nov 8, 2024
@jonahgao jonahgao added the api change Changes the API exposed to users of the crate label Nov 8, 2024
@@ -311,6 +311,7 @@ fn optimize_projections(
| LogicalPlan::Explain(_)
| LogicalPlan::Analyze(_)
| LogicalPlan::Subquery(_)
| LogicalPlan::Statement(_)
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a slt test for this change.

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.

This looks great -- thank you @jonahgao

}

// Manual implementation needed because of `schema` field. Comparison excludes this field.
impl PartialOrd for TransactionStart {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a nice cleanup (not to have a schema as a field 👌 nice

Copy link
Member

@Weijun-H Weijun-H left a comment

Choose a reason for hiding this comment

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

It is a neat cleanup! Thanks @jonahgao 👍

@jonahgao
Copy link
Member Author

jonahgao commented Nov 9, 2024

Thanks @alamb @Weijun-H for the review.

@jonahgao jonahgao merged commit 7a7c8cb into apache:main Nov 9, 2024
25 checks passed
@jonahgao jonahgao deleted the move_prepare branch November 9, 2024 03:39
jayzhan211 pushed a commit to jayzhan211/datafusion that referenced this pull request Nov 12, 2024
…13311)

* refactor: move PREPARE/EXECUTE into `LogicalPlan::Statement`

* Fix cargo doc

* Restore TableScan

* Fix cargo doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change Changes the API exposed to users of the crate core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules proto Related to proto crate sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants