Skip to content

Commit

Permalink
feat: provide invariant for UnionExec
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedld committed Jan 19, 2025
1 parent 9d854a6 commit 7b2f54b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions datafusion/physical-plan/src/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ use super::{
ExecutionPlanProperties, Partitioning, PlanProperties, RecordBatchStream,
SendableRecordBatchStream, Statistics,
};
use crate::execution_plan::{boundedness_from_children, emission_type_from_children};
use crate::execution_plan::{
boundedness_from_children, emission_type_from_children, InvariantLevel,
};
use crate::metrics::BaselineMetrics;
use crate::stream::ObservedStream;

use arrow::datatypes::{Field, Schema, SchemaRef};
use arrow::record_batch::RecordBatch;
use datafusion_common::stats::Precision;
use datafusion_common::{exec_err, internal_err, Result};
use datafusion_common::{exec_err, internal_err, DataFusionError, Result};
use datafusion_execution::TaskContext;
use datafusion_physical_expr::{calculate_union, EquivalenceProperties};

Expand Down Expand Up @@ -172,6 +174,14 @@ impl ExecutionPlan for UnionExec {
&self.cache
}

fn check_invariants(&self, _check: InvariantLevel) -> Result<()> {
(self.inputs().len() >= 2)
.then_some(())
.ok_or(DataFusionError::Internal(
"UnionExec should have at least 2 children".into(),
))
}

fn children(&self) -> Vec<&Arc<dyn ExecutionPlan>> {
self.inputs.iter().collect()
}
Expand Down

0 comments on commit 7b2f54b

Please sign in to comment.