Skip to content

Commit 9ffda97

Browse files
committed
moving function to more logical location
1 parent 8ddef97 commit 9ffda97

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

src/common/util.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,3 @@ pub fn display_plan_with_partition_in_out(plan: &dyn ExecutionPlan) -> Result<St
3636
visit(plan, 0, &mut f)?;
3737
Ok(f)
3838
}
39-
40-
/// Returns a boolean indicating if this stage can be divided into more than one task.
41-
///
42-
/// Some Plan nodes need to materialize all partitions inorder to execute such as
43-
/// NestedLoopJoinExec. Rewriting the plan to accommodate dividing it into tasks
44-
/// would result in redundant work.
45-
///
46-
/// The plans we cannot split are:
47-
/// - NestedLoopJoinExec
48-
pub fn can_be_divided(plan: &Arc<dyn ExecutionPlan>) -> Result<bool> {
49-
// recursively check to see if this stages plan contains a NestedLoopJoinExec
50-
let mut has_unsplittable_plan = false;
51-
let search = |f: &Arc<dyn ExecutionPlan>| {
52-
if f.as_any()
53-
.downcast_ref::<datafusion::physical_plan::joins::NestedLoopJoinExec>()
54-
.is_some()
55-
{
56-
has_unsplittable_plan = true;
57-
return Ok(TreeNodeRecursion::Stop);
58-
}
59-
60-
Ok(TreeNodeRecursion::Continue)
61-
};
62-
plan.apply(search)?;
63-
Ok(!has_unsplittable_plan)
64-
}

src/physical_optimizer.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::sync::Arc;
22

33
use super::stage::ExecutionStage;
4-
use crate::common::util::can_be_divided;
54
use crate::{plan::PartitionIsolatorExec, ArrowFlightReadExec};
65
use datafusion::common::tree_node::TreeNodeRecursion;
76
use datafusion::error::DataFusionError;
@@ -153,6 +152,32 @@ impl DistributedPhysicalOptimizerRule {
153152
}
154153
}
155154

155+
/// Returns a boolean indicating if this stage can be divided into more than one task.
156+
///
157+
/// Some Plan nodes need to materialize all partitions inorder to execute such as
158+
/// NestedLoopJoinExec. Rewriting the plan to accommodate dividing it into tasks
159+
/// would result in redundant work.
160+
///
161+
/// The plans we cannot split are:
162+
/// - NestedLoopJoinExec
163+
pub fn can_be_divided(plan: &Arc<dyn ExecutionPlan>) -> Result<bool> {
164+
// recursively check to see if this stages plan contains a NestedLoopJoinExec
165+
let mut has_unsplittable_plan = false;
166+
let search = |f: &Arc<dyn ExecutionPlan>| {
167+
if f.as_any()
168+
.downcast_ref::<datafusion::physical_plan::joins::NestedLoopJoinExec>()
169+
.is_some()
170+
{
171+
has_unsplittable_plan = true;
172+
return Ok(TreeNodeRecursion::Stop);
173+
}
174+
175+
Ok(TreeNodeRecursion::Continue)
176+
};
177+
plan.apply(search)?;
178+
Ok(!has_unsplittable_plan)
179+
}
180+
156181
#[cfg(test)]
157182
mod tests {
158183
use crate::assert_snapshot;

0 commit comments

Comments
 (0)