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

implement drop view #3267

Merged
merged 10 commits into from
Sep 3, 2022
Merged

implement drop view #3267

merged 10 commits into from
Sep 3, 2022

Conversation

kmitchener
Copy link
Contributor

@kmitchener kmitchener commented Aug 25, 2022

Which issue does this PR close?

Closes #3251.

Rationale for this change

What changes are included in this PR?

  • implement drop view and drop view if exists
  • change drop table so it only works on tables, not views
  • added tests for the above
  • added basic documentation for drop view

Are there any user-facing changes?

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

@DaltonModlin may be interested in this.

@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2022

Codecov Report

Merging #3267 (77759ff) into master (a49e01e) will decrease coverage by 0.01%.
The diff coverage is 73.56%.

@@            Coverage Diff             @@
##           master    #3267      +/-   ##
==========================================
- Coverage   85.48%   85.47%   -0.02%     
==========================================
  Files         294      294              
  Lines       54072    54130      +58     
==========================================
+ Hits        46223    46267      +44     
- Misses       7849     7863      +14     
Impacted Files Coverage Δ
datafusion/core/src/physical_plan/planner.rs 77.39% <0.00%> (ø)
datafusion/expr/src/logical_plan/plan.rs 77.11% <0.00%> (-0.95%) ⬇️
datafusion/expr/src/utils.rs 90.74% <ø> (ø)
...tafusion/optimizer/src/common_subexpr_eliminate.rs 92.07% <ø> (ø)
datafusion/optimizer/src/projection_push_down.rs 98.06% <ø> (ø)
datafusion/proto/src/logical_plan.rs 17.32% <0.00%> (-0.04%) ⬇️
datafusion/sql/src/planner.rs 80.34% <40.00%> (-0.13%) ⬇️
datafusion/core/tests/sql/create_drop.rs 93.70% <87.87%> (-2.05%) ⬇️
datafusion/core/src/execution/context.rs 78.75% <91.17%> (+0.51%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kmitchener kmitchener changed the title implement 'drop view' implement drop view Aug 25, 2022
@kmitchener kmitchener marked this pull request as ready for review August 25, 2022 19:42
@kmitchener
Copy link
Contributor Author

Functionality plus basic tests and docs added

@kmitchener
Copy link
Contributor Author

One thing I didn't do in this PR: re-export the new datafusion_expr::logical_plan::DropView struct via the "legacy" logical_plan module in core (datafusion::logical_plan:: ..). Should I re-export it or does legacy in this case mean that no new re-exports should happen there?

https://github.com/apache/arrow-datafusion/blob/master/datafusion/core/src/logical_plan/mod.rs#L18

Alternatively, should we create an issue to remove this legacy re-exporting?

@andygrove
Copy link
Member

Alternatively, should we create an issue to remove this legacy re-exporting?

We do have an issue already for this - #2683

We may want to deprecate this module for one release and then remove in the next.

DROP TABLE IF EXISTS nonexistent_table;
```

## DROP VIEW
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for improving the docs!

@kmitchener
Copy link
Contributor Author

@andygrove This is ready. Let me know what I can do to help get it committed. Thanks!

@kmitchener
Copy link
Contributor Author

@alamb is there someone that's suitable to review this and give feedback? this PR is blocking progress on other issues and it's not getting a review :( and I'm not sure how to proceed

@alamb
Copy link
Contributor

alamb commented Sep 3, 2022

SOrry @kmitchener -- I will review it now

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 @kmitchener -- thank you and I apologize again for the delay in review

schema: DFSchemaRef::new(DFSchema::empty()),
})),
_ => Err(DataFusionError::NotImplemented(
"Only `DROP TABLE/VIEW ...` statement is supported currently"
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -1019,6 +1030,17 @@ pub struct DropTable {
pub schema: DFSchemaRef,
}

/// Drops a view.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but it seems to me like requiring new LogicalPlan nodes for each type of DDL (CREATE, DROP, etc) is somewhat cumbersome. Maybe we can eventually refactor type of thing into LogicalPlan::DDL(DDL) and keep all the DDL related structs in their own structure. I'll file a follow on ticket for this

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed #3349 as a follow on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was wondering about this and follow on work for dropping schema, etc. A lot of plumbing here, and I'm not sure it works if you have your own CatalogProvider.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I was wondering about this and follow on work for dropping schema, etc. A lot of plumbing here, and I'm not sure it works if you have your own CatalogProvider.

I agree -- it does not work if you have your own CatalogProvider without some more work. I this behavior is fine, as long as the point is clear to users.

let plan = LogicalPlanBuilder::empty(false).build()?;
Ok(Arc::new(DataFrame::new(self.state.clone(), &plan)))
}
(true, false, Ok(_)) => self.return_empty_dataframe(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This change to refactor and reduce duplicated code, is a very nice example of leaving the code better than when you found it. It is very much appreciated @kmitchener


#[tokio::test]
#[should_panic(expected = "doesn't exist")]
async fn drop_view_cant_drop_table() {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 nice

@alamb alamb merged commit 5621e3b into apache:master Sep 3, 2022
@ursabot
Copy link

ursabot commented Sep 3, 2022

Benchmark runs are scheduled for baseline = 0fc7297 and contender = 5621e3b. 5621e3b 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

@kmitchener kmitchener deleted the 3251-drop-view-1 branch September 4, 2022 12:59
kmitchener added a commit to kmitchener/arrow-datafusion that referenced this pull request Sep 4, 2022
* add initial support for 'drop view'

* add tests

* add very basic docs

* add example to drop view doc

* ran prettier on the doc

* refactored, now done

* removed typo

* fix bad resolve merge conflict
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.

implement DROP VIEW
6 participants