Skip to content

Commit c31ab2e

Browse files
committed
Remove redundant plan from extension's check_invariants
In `UserDefinedLogicalNode::check_invariants`, the actual plan to check for invariants is `self`. The `plan` is always `LogicalPlan::Extension` and provides no further information. It's confusing.
1 parent 5af9075 commit c31ab2e

4 files changed

Lines changed: 7 additions & 15 deletions

File tree

‎datafusion/core/tests/user_defined/user_defined_plan.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ impl UserDefinedLogicalNodeCore for TopKPlanNode {
580580
self.input.schema()
581581
}
582582

583-
fn check_invariants(&self, check: InvariantLevel, _plan: &LogicalPlan) -> Result<()> {
583+
fn check_invariants(&self, check: InvariantLevel) -> Result<()> {
584584
if let Some(InvariantMock {
585585
should_fail_invariant,
586586
kind,

‎datafusion/expr/src/logical_plan/extension.rs‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
5757
fn schema(&self) -> &DFSchemaRef;
5858

5959
/// Perform check of invariants for the extension node.
60-
fn check_invariants(&self, check: InvariantLevel, plan: &LogicalPlan) -> Result<()>;
60+
fn check_invariants(&self, check: InvariantLevel) -> Result<()>;
6161

6262
/// Returns all expressions in the current logical plan node. This should
6363
/// not include expressions of any inputs (aka non-recursively).
@@ -241,11 +241,7 @@ pub trait UserDefinedLogicalNodeCore:
241241
/// Perform check of invariants for the extension node.
242242
///
243243
/// This is the default implementation for extension nodes.
244-
fn check_invariants(
245-
&self,
246-
_check: InvariantLevel,
247-
_plan: &LogicalPlan,
248-
) -> Result<()> {
244+
fn check_invariants(&self, _check: InvariantLevel) -> Result<()> {
249245
Ok(())
250246
}
251247

@@ -334,8 +330,8 @@ impl<T: UserDefinedLogicalNodeCore> UserDefinedLogicalNode for T {
334330
self.schema()
335331
}
336332

337-
fn check_invariants(&self, check: InvariantLevel, plan: &LogicalPlan) -> Result<()> {
338-
self.check_invariants(check, plan)
333+
fn check_invariants(&self, check: InvariantLevel) -> Result<()> {
334+
self.check_invariants(check)
339335
}
340336

341337
fn expressions(&self) -> Vec<Expr> {

‎datafusion/expr/src/logical_plan/invariants.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn assert_executable_invariants(plan: &LogicalPlan) -> Result<()> {
7474
fn assert_valid_extension_nodes(plan: &LogicalPlan, check: InvariantLevel) -> Result<()> {
7575
plan.apply_with_subqueries(|plan: &LogicalPlan| {
7676
if let LogicalPlan::Extension(Extension { node }) = plan {
77-
node.check_invariants(check, plan)?;
77+
node.check_invariants(check)?;
7878
}
7979
plan.apply_expressions(|expr| {
8080
// recursively look for subqueries

‎datafusion/substrait/tests/cases/roundtrip_logical_plan.rs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ impl UserDefinedLogicalNode for MockUserDefinedLogicalPlan {
112112
&self.empty_schema
113113
}
114114

115-
fn check_invariants(
116-
&self,
117-
_check: InvariantLevel,
118-
_plan: &LogicalPlan,
119-
) -> Result<()> {
115+
fn check_invariants(&self, _check: InvariantLevel) -> Result<()> {
120116
Ok(())
121117
}
122118

0 commit comments

Comments
 (0)