Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use datafusion::physical_expr::EquivalenceProperties;
use datafusion::physical_plan::execution_plan::{Boundedness, EmissionType};
use datafusion::physical_plan::memory::MemoryStream;
use datafusion::physical_plan::{
DisplayAs, DisplayFormatType, ExecutionPlan, Partitioning, PlanProperties,
SendableRecordBatchStream, project_schema,
ChildrenPropertiesHint, DisplayAs, DisplayFormatType, ExecutionPlan, Partitioning,
PlanProperties, SendableRecordBatchStream, project_schema,
};
use datafusion::prelude::*;

Expand Down Expand Up @@ -267,13 +267,21 @@ impl ExecutionPlan for CustomExec {
vec![]
}

fn with_new_children(
fn replace_children(
self: Arc<Self>,
_: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
Ok(self)
}

fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}

fn execute(
&self,
_partition: usize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use datafusion::execution::{SendableRecordBatchStream, TaskContext};
use datafusion::logical_expr::LogicalPlanBuilder;
use datafusion::physical_plan::stream::RecordBatchStreamAdapter;
use datafusion::physical_plan::{
DisplayAs, DisplayFormatType, ExecutionPlan, PlanProperties,
ChildrenPropertiesHint, DisplayAs, DisplayFormatType, ExecutionPlan, PlanProperties,
};
use datafusion::prelude::*;
use futures::stream::{StreamExt, TryStreamExt};
Expand Down Expand Up @@ -236,9 +236,10 @@ impl ExecutionPlan for BufferingExecutionPlan {
vec![&self.input]
}

fn with_new_children(
fn replace_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
_hint: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
if children.len() == 1 {
Ok(Arc::new(BufferingExecutionPlan::new(
Expand All @@ -250,6 +251,13 @@ impl ExecutionPlan for BufferingExecutionPlan {
}
}

fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}

fn execute(
&self,
partition: usize,
Expand Down
25 changes: 21 additions & 4 deletions datafusion-examples/examples/proto/composed_extension_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use std::sync::Arc;
use datafusion::common::Result;
use datafusion::common::internal_err;
use datafusion::execution::TaskContext;
use datafusion::physical_plan::ChildrenPropertiesHint;
use datafusion::physical_plan::{DisplayAs, ExecutionPlan};
use datafusion::prelude::SessionContext;
use datafusion_proto::physical_plan::{
Expand Down Expand Up @@ -110,13 +111,21 @@ impl ExecutionPlan for ParentExec {
vec![&self.input]
}

fn with_new_children(
fn replace_children(
self: Arc<Self>,
_children: Vec<Arc<dyn ExecutionPlan>>,
_: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
unreachable!()
}

fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}

fn execute(
&self,
_partition: usize,
Expand Down Expand Up @@ -188,13 +197,21 @@ impl ExecutionPlan for ChildExec {
vec![]
}

fn with_new_children(
fn replace_children(
self: Arc<Self>,
_children: Vec<Arc<dyn ExecutionPlan>>,
_: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
unreachable!()
}

fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}

fn execute(
&self,
_partition: usize,
Expand Down
15 changes: 13 additions & 2 deletions datafusion-examples/examples/relation_planner/table_sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ use futures::{
use rand::{Rng, SeedableRng, rngs::StdRng};
use tonic::async_trait;

use datafusion::optimizer::simplify_expressions::simplify_literal::parse_literal;
use datafusion::{
execution::{
RecordBatchStream, SendableRecordBatchStream, SessionState, SessionStateBuilder,
Expand All @@ -115,6 +114,10 @@ use datafusion::{
physical_planner::{DefaultPhysicalPlanner, ExtensionPlanner, PhysicalPlanner},
prelude::*,
};
use datafusion::{
optimizer::simplify_expressions::simplify_literal::parse_literal,
physical_plan::ChildrenPropertiesHint,
};
use datafusion_common::{
DFSchemaRef, DataFusionError, Result, Statistics, internal_err, not_impl_err,
plan_datafusion_err, plan_err,
Expand Down Expand Up @@ -697,9 +700,10 @@ impl ExecutionPlan for SampleExec {
vec![&self.input]
}

fn with_new_children(
fn replace_children(
self: Arc<Self>,
mut children: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
Ok(Arc::new(Self::try_new(
children.swap_remove(0),
Expand All @@ -709,6 +713,13 @@ impl ExecutionPlan for SampleExec {
)?))
}

fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}

fn execute(
&self,
partition: usize,
Expand Down
16 changes: 12 additions & 4 deletions datafusion/catalog/src/memory/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ use datafusion_physical_expr::{
use datafusion_physical_plan::repartition::RepartitionExec;
use datafusion_physical_plan::stream::RecordBatchStreamAdapter;
use datafusion_physical_plan::{
DisplayAs, DisplayFormatType, ExecutionPlan, Partitioning, PlanProperties,
collect_partitioned,
ChildrenPropertiesHint, DisplayAs, DisplayFormatType, ExecutionPlan, Partitioning,
PlanProperties, collect_partitioned,
};
use datafusion_session::Session;

Expand Down Expand Up @@ -571,13 +571,21 @@ impl ExecutionPlan for DmlResultExec {
vec![]
}

fn with_new_children(
fn replace_children(
self: Arc<Self>,
_children: Vec<Arc<dyn ExecutionPlan>>,
_: Vec<Arc<dyn ExecutionPlan>>,
_: datafusion_physical_plan::ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
Ok(self)
}

fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}

fn execute(
&self,
_partition: usize,
Expand Down
42 changes: 36 additions & 6 deletions datafusion/core/src/physical_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3389,6 +3389,7 @@ mod tests {
use datafusion_functions_aggregate::count::{count_all, count_udaf};
use datafusion_functions_aggregate::expr_fn::sum;
use datafusion_physical_expr::EquivalenceProperties;
use datafusion_physical_plan::ChildrenPropertiesHint;
use datafusion_physical_plan::execution_plan::{Boundedness, EmissionType};

fn make_session_state() -> SessionState {
Expand Down Expand Up @@ -4693,9 +4694,10 @@ mod tests {
vec![]
}

fn with_new_children(
fn replace_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
if children.is_empty() {
Ok(self)
Expand All @@ -4704,6 +4706,13 @@ mod tests {
}
}

fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}

fn execute(
&self,
_partition: usize,
Expand Down Expand Up @@ -4856,12 +4865,19 @@ digraph {
fn name(&self) -> &str {
"always ok"
}
fn with_new_children(
fn replace_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
Ok(Arc::new(Self(children)))
}
fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}
fn schema(&self) -> SchemaRef {
Arc::new(Schema::empty())
}
Expand Down Expand Up @@ -4905,12 +4921,19 @@ digraph {
fn schema(&self) -> SchemaRef {
Arc::new(Schema::empty())
}
fn with_new_children(
fn replace_children(
self: Arc<Self>,
_children: Vec<Arc<dyn ExecutionPlan>>,
_: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
unimplemented!()
}
fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}
fn children(&self) -> Vec<&Arc<dyn ExecutionPlan>> {
unimplemented!()
}
Expand Down Expand Up @@ -5029,12 +5052,19 @@ digraph {
fn schema(&self) -> SchemaRef {
Arc::new(Schema::empty())
}
fn with_new_children(
fn replace_children(
self: Arc<Self>,
_children: Vec<Arc<dyn ExecutionPlan>>,
_: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
unimplemented!()
}
fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}
fn children(&self) -> Vec<&Arc<dyn ExecutionPlan>> {
vec![]
}
Expand Down
12 changes: 10 additions & 2 deletions datafusion/core/tests/custom_sources_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ use datafusion_common::cast::as_primitive_array;
use datafusion_common::project_schema;
use datafusion_common::stats::Precision;
use datafusion_physical_expr::EquivalenceProperties;
use datafusion_physical_plan::PlanProperties;
use datafusion_physical_plan::StatisticsArgs;
use datafusion_physical_plan::execution_plan::{Boundedness, EmissionType};
use datafusion_physical_plan::placeholder_row::PlaceholderRowExec;
use datafusion_physical_plan::{ChildrenPropertiesHint, PlanProperties};

use async_trait::async_trait;
use futures::stream::Stream;
Expand Down Expand Up @@ -164,13 +164,21 @@ impl ExecutionPlan for CustomExecutionPlan {
vec![]
}

fn with_new_children(
fn replace_children(
self: Arc<Self>,
_: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
Ok(self)
}

fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}

fn execute(
&self,
_partition: usize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use datafusion_common::{DataFusionError, internal_err, not_impl_err};
use datafusion_expr::expr::{BinaryExpr, Cast};
use datafusion_functions_aggregate::expr_fn::count;
use datafusion_physical_expr::EquivalenceProperties;
use datafusion_physical_plan::ChildrenPropertiesHint;
use datafusion_physical_plan::execution_plan::{Boundedness, EmissionType};

use async_trait::async_trait;
Expand Down Expand Up @@ -116,9 +117,10 @@ impl ExecutionPlan for CustomPlan {
vec![]
}

fn with_new_children(
fn replace_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
_: ChildrenPropertiesHint,
) -> Result<Arc<dyn ExecutionPlan>> {
// CustomPlan has no children
if children.is_empty() {
Expand All @@ -128,6 +130,13 @@ impl ExecutionPlan for CustomPlan {
}
}

fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
self.replace_children(children, ChildrenPropertiesHint::Recompute)
}

fn execute(
&self,
_partition: usize,
Expand Down
Loading
Loading