-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Create new datafusion-optimizer crate for logical optimizer rules
#2675
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
99d2f20
move most optimizer rules to new datafusion-optimizer crate
andygrove bb0df21
remove unused code
andygrove f6ed4c6
remove copy of user_defined
andygrove 72fd04d
move user_defined
andygrove 38867fa
Merge remote-tracking branch 'apache/master' into optimizer-crate
andygrove 4949312
cargo fmt
andygrove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| [package] | ||
| name = "datafusion-optimizer" | ||
| description = "DataFusion Query Optimizer" | ||
| version = "8.0.0" | ||
| homepage = "https://github.com/apache/arrow-datafusion" | ||
| repository = "https://github.com/apache/arrow-datafusion" | ||
| readme = "README.md" | ||
| authors = ["Apache Arrow <dev@arrow.apache.org>"] | ||
| license = "Apache-2.0" | ||
| keywords = [ "datafusion", "query", "optimizer" ] | ||
| edition = "2021" | ||
| rust-version = "1.59" | ||
|
|
||
| [lib] | ||
| name = "datafusion_optimizer" | ||
| path = "src/lib.rs" | ||
|
|
||
| [features] | ||
| default = ["unicode_expressions"] | ||
| unicode_expressions = [] | ||
|
|
||
| [dependencies] | ||
| arrow = { version = "15.0.0", features = ["prettyprint"] } | ||
| async-trait = "0.1.41" | ||
| chrono = { version = "0.4", default-features = false } | ||
| datafusion-common = { path = "../common", version = "8.0.0" } | ||
| datafusion-expr = { path = "../expr", version = "8.0.0" } | ||
| hashbrown = { version = "0.12", features = ["raw"] } | ||
| log = "^0.4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <!--- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
|
|
||
| # DataFusion Query Optimizer Rules | ||
|
|
||
| [DataFusion](df) is an extensible query execution framework, written in Rust, that uses Apache Arrow as its in-memory format. | ||
|
|
||
| This crate is a submodule of DataFusion that provides query optimizer rules. | ||
|
|
||
| [df]: https://crates.io/crates/datafusion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| pub mod common_subexpr_eliminate; | ||
| pub mod eliminate_filter; | ||
| pub mod eliminate_limit; | ||
| pub mod filter_push_down; | ||
| pub mod limit_push_down; | ||
| pub mod optimizer; | ||
| pub mod projection_push_down; | ||
| pub mod single_distinct_to_groupby; | ||
| pub mod subquery_filter_to_join; | ||
| pub mod utils; | ||
|
|
||
| #[cfg(test)] | ||
| pub mod test; | ||
|
|
||
| pub use optimizer::{OptimizerConfig, OptimizerRule}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| use arrow::datatypes::{DataType, Field, Schema}; | ||
| use datafusion_common::Result; | ||
| use datafusion_expr::{logical_plan::table_scan, LogicalPlan, LogicalPlanBuilder}; | ||
|
|
||
| pub mod user_defined; | ||
|
|
||
| /// some tests share a common table with different names | ||
| pub fn test_table_scan_with_name(name: &str) -> Result<LogicalPlan> { | ||
| let schema = Schema::new(vec![ | ||
| Field::new("a", DataType::UInt32, false), | ||
| Field::new("b", DataType::UInt32, false), | ||
| Field::new("c", DataType::UInt32, false), | ||
| ]); | ||
| table_scan(Some(name), &schema, None)?.build() | ||
| } | ||
|
|
||
| /// some tests share a common table | ||
| pub fn test_table_scan() -> Result<LogicalPlan> { | ||
| test_table_scan_with_name("test") | ||
| } | ||
|
|
||
| /// Scan an empty data source, mainly used in tests | ||
| pub fn scan_empty( | ||
| name: Option<&str>, | ||
| table_schema: &Schema, | ||
| projection: Option<Vec<usize>>, | ||
| ) -> Result<LogicalPlanBuilder> { | ||
| table_scan(name, table_schema, projection) | ||
| } | ||
|
|
||
| pub fn assert_fields_eq(plan: &LogicalPlan, expected: Vec<&str>) { | ||
| let actual: Vec<String> = plan | ||
| .schema() | ||
| .fields() | ||
| .iter() | ||
| .map(|f| f.name().clone()) | ||
| .collect(); | ||
| assert_eq!(actual, expected); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These functions don't appear to be being used by any tests that haven't also been moved, so perhaps they could be removed from core also?
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.
I have removed this from core now