-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Enhance/Refactor Ordering Equivalence Properties #7566
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
Changes from 32 commits
ea83c37
0d9f208
4ad5ec5
016558b
8007b1b
5d896a8
b8def0a
8850f33
0d32ca5
aac0a0c
f0dbd85
7112a25
ec41194
b16ad15
717631e
b93cc5d
b832b2d
5a92633
858576b
09aa6c8
7212e56
49ea333
eb81b43
18c4bab
fe322b4
0cb1ee2
cff6f2f
6cb4d5a
ef994fb
0290184
4fe9c0d
1c1de0d
23e30ae
abe0f31
2eaf755
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,12 +41,13 @@ use datafusion_common::{plan_err, DataFusionError, Result}; | |
| use datafusion_execution::TaskContext; | ||
| use datafusion_expr::Operator; | ||
| use datafusion_physical_expr::expressions::BinaryExpr; | ||
| use datafusion_physical_expr::intervals::utils::check_support; | ||
| use datafusion_physical_expr::{ | ||
| analyze, split_conjunction, AnalysisContext, ExprBoundaries, | ||
| OrderingEquivalenceProperties, PhysicalExpr, | ||
| }; | ||
|
|
||
| use datafusion_physical_expr::intervals::utils::check_support; | ||
| use datafusion_physical_expr::utils::collect_columns; | ||
| use futures::stream::{Stream, StreamExt}; | ||
| use log::trace; | ||
|
|
||
|
|
@@ -153,7 +154,19 @@ impl ExecutionPlan for FilterExec { | |
| } | ||
|
|
||
| fn ordering_equivalence_properties(&self) -> OrderingEquivalenceProperties { | ||
| self.input.ordering_equivalence_properties() | ||
| let stats = self.statistics(); | ||
| // Add the columns that have only one value (singleton) after filtering to constants. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is there a a difference between In other words, if the filter has a predicate like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In this case, statistics should be able to determine |
||
| if let Some(col_stats) = stats.column_statistics { | ||
| let constants = collect_columns(self.predicate()) | ||
| .into_iter() | ||
| .filter(|column| col_stats[column.index()].is_singleton()) | ||
| .map(|column| Arc::new(column) as Arc<dyn PhysicalExpr>) | ||
| .collect::<Vec<_>>(); | ||
| let filter_oeq = self.input.ordering_equivalence_properties(); | ||
| filter_oeq.with_constants(constants) | ||
| } else { | ||
| self.input.ordering_equivalence_properties() | ||
| } | ||
| } | ||
|
|
||
| fn with_new_children( | ||
|
|
@@ -197,7 +210,14 @@ impl ExecutionPlan for FilterExec { | |
| let input_stats = self.input.statistics(); | ||
| let input_column_stats = match input_stats.column_statistics { | ||
| Some(stats) => stats, | ||
| None => return Statistics::default(), | ||
| None => self | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems like it is more general than just for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with you. We can remove |
||
| .schema() | ||
| .fields | ||
| .iter() | ||
| .map(|field| { | ||
| ColumnStatistics::new_with_unbounded_column(field.data_type()) | ||
| }) | ||
| .collect::<Vec<_>>(), | ||
| }; | ||
|
|
||
| let starter_ctx = | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.