-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Part3] Partition and Sort Enforcement, Enforcement rule implementation #4122
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 all commits
a5bad1d
5cef4ec
6b2a677
881db1b
40e2021
d09d049
50dc5f6
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 |
|---|---|---|
|
|
@@ -73,7 +73,6 @@ use crate::optimizer::optimizer::{OptimizerConfig, OptimizerRule}; | |
| use datafusion_sql::{ResolvedTableReference, TableReference}; | ||
|
|
||
| use crate::physical_optimizer::coalesce_batches::CoalesceBatches; | ||
| use crate::physical_optimizer::merge_exec::AddCoalescePartitionsExec; | ||
| use crate::physical_optimizer::repartition::Repartition; | ||
|
|
||
| use crate::config::{ | ||
|
|
@@ -82,6 +81,7 @@ use crate::config::{ | |
| }; | ||
| use crate::datasource::file_format::file_type::{FileCompressionType, FileType}; | ||
| use crate::execution::{runtime_env::RuntimeEnv, FunctionRegistry}; | ||
| use crate::physical_optimizer::enforcement::BasicEnforcement; | ||
| use crate::physical_plan::file_format::{plan_to_csv, plan_to_json, plan_to_parquet}; | ||
| use crate::physical_plan::planner::DefaultPhysicalPlanner; | ||
| use crate::physical_plan::udaf::AggregateUDF; | ||
|
|
@@ -1207,6 +1207,8 @@ pub struct SessionConfig { | |
| pub parquet_pruning: bool, | ||
| /// Should DataFusion collect statistics after listing files | ||
| pub collect_statistics: bool, | ||
| /// Should DataFusion optimizer run a top down process to reorder the join keys | ||
| pub top_down_join_key_reordering: bool, | ||
| /// Configuration options | ||
| pub config_options: Arc<RwLock<ConfigOptions>>, | ||
| /// Opaque extensions. | ||
|
|
@@ -1226,6 +1228,7 @@ impl Default for SessionConfig { | |
| repartition_windows: true, | ||
| parquet_pruning: true, | ||
| collect_statistics: false, | ||
| top_down_join_key_reordering: true, | ||
| config_options: Arc::new(RwLock::new(ConfigOptions::new())), | ||
| // Assume no extensions by default. | ||
| extensions: HashMap::with_capacity_and_hasher( | ||
|
|
@@ -1548,6 +1551,7 @@ impl SessionState { | |
| Arc::new(AggregateStatistics::new()), | ||
| Arc::new(HashBuildProbeOrder::new()), | ||
| ]; | ||
| physical_optimizers.push(Arc::new(BasicEnforcement::new())); | ||
| if config | ||
| .config_options | ||
| .read() | ||
|
|
@@ -1565,7 +1569,8 @@ impl SessionState { | |
| ))); | ||
| } | ||
| physical_optimizers.push(Arc::new(Repartition::new())); | ||
| physical_optimizers.push(Arc::new(AddCoalescePartitionsExec::new())); | ||
| physical_optimizers.push(Arc::new(BasicEnforcement::new())); | ||
| // physical_optimizers.push(Arc::new(AddCoalescePartitionsExec::new())); | ||
|
Member
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 remove it?
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. The new rule BasicEnforcement had already covered the work of AddCoalescePartitionsExec.
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. When this call is removed, there is no other code that calls
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. Sure, I will do it in the following PR. |
||
|
|
||
| SessionState { | ||
| session_id, | ||
|
|
||
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.
Is there a reason that
BasicEnforcementmust be run twice?Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, this is to cover the case that Repartition rule could add additional RepartitionExec with RoundRobin partitioning, and to make sure the SinglePartition is satisfied, we run the BasicEnforcement again. Originally it was the AddCoalescePartitionsExec here, now I replace AddCoalescePartitionsExec with BasicEnforcement.
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.
Cool -- perhaps you can add a comment to explain the rationale
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.
Sure, I will do it in the following PR.