milenkovicm commented on code in PR #1594:
URL:
https://github.com/apache/datafusion-ballista/pull/1594#discussion_r3147313279
##########
ballista/scheduler/src/state/aqe/planner.rs:
##########
@@ -445,13 +444,6 @@ impl AdaptivePlanner {
let default_optimizers = PhysicalOptimizer::new();
physical_optimizers.extend(default_optimizers.rules.iter().cloned());
physical_optimizers.push(Arc::new(PropagateEmptyExecRule::default()));
- // this rule is not required anymore
- //
physical_optimizers.push(Arc::new(EliminateRoundRobbinRule::default()));
-
physical_optimizers.push(Arc::new(EliminateCooperativeExecRule::default()));
- // we should remove it at the later stage
- // this is just temporary to detect possible duplicate
- // execs
- physical_optimizers.push(Arc::new(WarnOnDuplicateExecRule::default()));
Review Comment:
can we keep this for now? it might detect issues in the future
##########
ballista/scheduler/src/state/aqe/optimizer_rule/datafusion_patch.rs:
##########
@@ -1,165 +0,0 @@
-// 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.
-
-//! Some datafusion rules are not idempotent, thus set of
-//! physical plan rules needed to fix them.
-//!
-//! Datafusion needs to be patched, until then
-//! we keep the rules.
-use datafusion::common::tree_node::{Transformed, TransformedResult, TreeNode};
-use datafusion::config::ConfigOptions;
-use datafusion::physical_optimizer::PhysicalOptimizerRule;
-use datafusion::physical_plan::coop::CooperativeExec;
-use datafusion::physical_plan::repartition::RepartitionExec;
-use datafusion::physical_plan::{ExecutionPlan, displayable, execution_plan};
-use log::warn;
-use std::sync::Arc;
-
-// not required anymore
-#[allow(dead_code)]
-#[derive(Debug, Clone, Default)]
-pub struct EliminateRoundRobbinRule {}
-impl EliminateRoundRobbinRule {
- fn transform(
- execution_plan: Arc<dyn ExecutionPlan>,
- ) -> datafusion::error::Result<Transformed<Arc<dyn ExecutionPlan>>> {
- if let Some(repartition) =
- execution_plan.as_any().downcast_ref::<RepartitionExec>()
- {
- match repartition.partitioning() {
- execution_plan::Partitioning::RoundRobinBatch(_) => {
- Ok(Transformed::yes(repartition.input().clone()))
- }
- _ => Ok(Transformed::no(execution_plan)),
- }
- } else {
- Ok(Transformed::no(execution_plan))
- }
- }
-}
-
-impl PhysicalOptimizerRule for EliminateRoundRobbinRule {
- fn optimize(
- &self,
- execution_plan: Arc<dyn ExecutionPlan>,
- _config: &datafusion::config::ConfigOptions,
- ) -> datafusion::error::Result<Arc<dyn ExecutionPlan>> {
- Ok(execution_plan.transform_up(Self::transform)?.data)
- }
-
- fn name(&self) -> &str {
- "EliminateRoundRobbinRule"
- }
-
- fn schema_check(&self) -> bool {
- false
- }
-}
-
-/// In some cases double [CooperativeExec] will be inserted.
-/// Until we get chance to investigate the issue this rule will
-/// eliminate doubles
-//
-// TODO: this has been fixed in datafusion 53, should be removed when updated
-//
-#[derive(Debug, Clone, Default)]
-pub struct EliminateCooperativeExecRule {}
-/// for some reason double CoalesceBatchesExec
-/// show
-impl EliminateCooperativeExecRule {
- fn transform(
- execution_plan: Arc<dyn ExecutionPlan>,
- ) -> datafusion::error::Result<Transformed<Arc<dyn ExecutionPlan>>> {
- if let Some(coalesce) =
execution_plan.as_any().downcast_ref::<CooperativeExec>()
- {
- if coalesce
- .input()
- .as_any()
- .downcast_ref::<CooperativeExec>()
- .is_some()
- {
- Ok(Transformed::yes(coalesce.input().clone()))
- } else {
- Ok(Transformed::no(execution_plan))
- }
- } else {
- Ok(Transformed::no(execution_plan))
- }
- }
-}
-
-impl PhysicalOptimizerRule for EliminateCooperativeExecRule {
- fn optimize(
- &self,
- execution_plan: Arc<dyn ExecutionPlan>,
- _config: &datafusion::config::ConfigOptions,
- ) -> datafusion::error::Result<Arc<dyn ExecutionPlan>> {
- let result = execution_plan.transform_up(Self::transform)?;
- Ok(result.data)
- }
-
- fn name(&self) -> &str {
- "EliminateCooperativeExecRule"
- }
-
- fn schema_check(&self) -> bool {
- false
- }
-}
-/// This rule is just for DEBUG purposes as some
-/// physical rules are not idempotent.
-#[derive(Debug, Clone, Default)]
-pub struct WarnOnDuplicateExecRule {}
-
-impl WarnOnDuplicateExecRule {
- fn transform(
- execution_plan: Arc<dyn ExecutionPlan>,
- ) -> datafusion::error::Result<Transformed<Arc<dyn ExecutionPlan>>> {
- let exec_name = execution_plan.name();
- if execution_plan
- .children()
- .iter()
- .any(|child| child.name() == exec_name)
- {
- warn!(
- "there might be a duplicated exec with name {},\n {}",
- exec_name,
- displayable(execution_plan.as_ref()).indent(false)
- );
- }
-
- Ok(Transformed::no(execution_plan))
- }
-}
-
-impl PhysicalOptimizerRule for WarnOnDuplicateExecRule {
Review Comment:
lets keep this one for now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]