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

Add insert/update/delete to LogicalPlan and add SQL planner support #4902

Merged
merged 7 commits into from
Jan 17, 2023

Conversation

avantgardnerio
Copy link
Contributor

Which issue does this PR close?

Closes #4901.

Rationale for this change

Described in issue.

What changes are included in this PR?

  • A new LogicalPlan enum variant called WriteRel and modeled after Substrait
  • Changes to the planner to allow it to generate the new plans
  • Integration tests for insert/update/delete

Are these changes tested?

Yes

Are there any user-facing changes?

Only if the user is a programmer using DataFusion as a library, in which case more ASTs will convert to LogicalPlans.

@github-actions github-actions bot added core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules sql SQL Planner labels Jan 13, 2023
@avantgardnerio
Copy link
Contributor Author

@andygrove @alamb I'd love to hear your thoughts on this.

@alamb alamb changed the title Add insert/update/delete to LogicalPlan Add insert/update/delete to LogicalPlan and add SQL planner support Jan 13, 2023
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.

I think this is looking quite nice @avantgardnerio -- I need to review it when I have a bit more brain power.

My biggest reaction is to the need to start namespacing the LogicalPlan a bit more -- but the WriteRel is a good model to follow (e.g. for DML)

datafusion/core/src/physical_plan/planner.rs Outdated Show resolved Hide resolved
datafusion/expr/src/logical_plan/plan.rs Show resolved Hide resolved
datafusion/expr/src/logical_plan/plan.rs Outdated Show resolved Hide resolved
datafusion/sql/src/statement.rs Outdated Show resolved Hide resolved
datafusion/sql/src/statement.rs Outdated Show resolved Hide resolved
datafusion/sql/src/statement.rs Outdated Show resolved Hide resolved
datafusion/sql/src/statement.rs Show resolved Hide resolved
datafusion/sql/src/statement.rs Outdated Show resolved Hide resolved
let sql = "delete from person where id=1";
let plan = r#"
Write: op=[Delete] table=[person]
Filter: id = Int64(1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No projection needed for delete I assume?

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @avantgardnerio

@@ -1180,6 +1180,12 @@ impl DefaultPhysicalPlanner {
"Unsupported logical plan: CreateView".to_string(),
))
}
LogicalPlan::Dml(_) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

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.

Looks good to me -- thank you @avantgardnerio

"Insert-returning clause not yet supported".to_owned(),
))?;
}
let _ = into; // optional keyword doesn't change behavior
Copy link
Contributor

Choose a reason for hiding this comment

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

awesome

@alamb alamb merged commit aa8f139 into apache:master Jan 17, 2023
@ursabot
Copy link

ursabot commented Jan 17, 2023

Benchmark runs are scheduled for baseline = 279440b and contender = aa8f139. aa8f139 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@avantgardnerio avantgardnerio deleted the bg_write_rel branch January 17, 2023 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add insert/update/delete/(ctas?) to DataFusion planner
4 participants