You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/07/05 12:52:32 UTC
(datafusion) 01/01: fix: gate debug-only assertions in physical planner test test_optimization_invariant_checker (#23323)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-23323-7b1bffaaffa3ace1c059722ee5493e3f289f203a
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit 6a0e76ed692afaafd616e0d98d51bef63c1ff02d
Author: Burak Şen <bu...@gmail.com>
AuthorDate: Sun Jul 5 15:52:08 2026 +0300
fix: gate debug-only assertions in physical planner test test_optimization_invariant_checker (#23323)
## Which issue does this PR close?
- Closes #20786
## Rationale for this change
`test_optimization_invariant_checker` panics under `release-nonlto`
profile which has debug_assertions=false. Thus, we need to gate
## What changes are included in this PR?
Make sure debug_assertion required places are behind that gate
## Are these changes tested?
Yes and this is test only change.
```
cargo test physical_planner --profile release-nonlto
```
now passes since we skip these checks as they are not supported in that
profile
## Are there any user-facing changes?
No
---
datafusion/core/src/physical_planner.rs | 34 +++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs
index e93f6d5a55..b6d28e7b21 100644
--- a/datafusion/core/src/physical_planner.rs
+++ b/datafusion/core/src/physical_planner.rs
@@ -4770,16 +4770,21 @@ digraph {
.unwrap_err();
assert!(expected_err.to_string().contains("PhysicalOptimizer rule 'OptimizerRuleWithSchemaCheck' failed. Schema mismatch. Expected original schema"));
+ // The recursive `check_invariants` walk only runs under `debug_assertions`
+ // (see `OptimizationInvariantChecker::check`). In release builds the walk is
+ // skipped, so the checker returns `Ok` rather than surfacing the node's error.
+
// Test: should fail when extension node fails it's own invariant check
let failing_node: Arc<dyn ExecutionPlan> = Arc::new(InvariantFailsExtensionNode);
- let expected_err = OptimizationInvariantChecker::new(&rule)
- .check(&failing_node, &ok_plan.schema())
- .unwrap_err();
- assert!(
- expected_err.to_string().contains(
+ let result = OptimizationInvariantChecker::new(&rule)
+ .check(&failing_node, &ok_plan.schema());
+ if cfg!(debug_assertions) {
+ assert!(result.unwrap_err().to_string().contains(
"extension node failed it's user-defined always-invariant check"
- )
- );
+ ));
+ } else {
+ assert!(result.is_ok());
+ }
// Test: should fail when descendent extension node fails
let failing_node: Arc<dyn ExecutionPlan> = Arc::new(InvariantFailsExtensionNode);
@@ -4787,14 +4792,15 @@ digraph {
Arc::clone(&child).with_new_children(vec![Arc::clone(&failing_node)])?,
Arc::clone(&child),
])?;
- let expected_err = OptimizationInvariantChecker::new(&rule)
- .check(&invalid_plan, &ok_plan.schema())
- .unwrap_err();
- assert!(
- expected_err.to_string().contains(
+ let result = OptimizationInvariantChecker::new(&rule)
+ .check(&invalid_plan, &ok_plan.schema());
+ if cfg!(debug_assertions) {
+ assert!(result.unwrap_err().to_string().contains(
"extension node failed it's user-defined always-invariant check"
- )
- );
+ ));
+ } else {
+ assert!(result.is_ok());
+ }
Ok(())
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org