jonahgao commented on code in PR #13651:
URL: https://github.com/apache/datafusion/pull/13651#discussion_r1871443351
##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -451,6 +468,33 @@ impl Optimizer {
}
}
+/// These are invariants to hold true for each logical plan.
+/// Do necessary check and fail the invalid plan.
+///
+/// Checks for elements which are immutable across optimizer passes.
+fn check_plan(
+ check_name: &str,
+ plan: &LogicalPlan,
+ prev_schema: Arc<DFSchema>,
+) -> Result<()> {
+ // verify invariant: optimizer rule didn't change the schema
+ assert_schema_is_the_same(check_name, &prev_schema, plan)?;
+
+ // verify invariant: fields must have unique names
+ assert_unique_field_names(plan)?;
+
+ /* This current fails for:
+ - execution::context::tests::cross_catalog_access
+ - at test_files/string/string.slt:46
+ External error: query failed: DataFusion error: Optimizer rule
'eliminate_nested_union' failed
+ */
+ // verify invariant: equivalent schema across union inputs
+ // assert_unions_are_valid(check_name, plan)?;
+
+ // TODO: trait API and provide extension on the Optimizer to define own
validations?
Review Comment:
Maybe it can be controlled through environment variables, similar to
`RUST_LOG` or `RUST_BACKTRACE`. Enable it for debugging when problems are
encountered or during an upgrade.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]