MCPcopy Create free account
hub / github.com/apache/datafusion / assert_valid_optimization

Function assert_valid_optimization

datafusion/optimizer/src/optimizer.rs:502–511  ·  view source on GitHub ↗

These are invariants which should hold true before and after [`LogicalPlan`] optimization. This differs from [`LogicalPlan::check_invariants`], which addresses if a singular LogicalPlan is valid. Instead, this address if the optimization was valid based upon permitted changes.

(
    plan: &LogicalPlan,
    prev_schema: &Arc<DFSchema>,
)

Source from the content-addressed store, hash-verified

500/// This differs from [`LogicalPlan::check_invariants`], which addresses if a singular
501/// LogicalPlan is valid. Instead, this address if the optimization was valid based upon permitted changes.
502fn assert_valid_optimization(
503 plan: &LogicalPlan,
504 prev_schema: &Arc<DFSchema>,
505) -> Result<()> {
506 // verify invariant: optimizer passes should not change the schema if the schema can't be cast from the previous schema.
507 // Refer to <https://datafusion.apache.org/contributor-guide/specification/invariants.html#logical-schema-is-invariant-under-logical-optimization>
508 assert_expected_schema(prev_schema, plan)?;
509
510 Ok(())
511}
512
513#[cfg(test)]
514mod tests {

Callers 1

optimizeMethod · 0.85

Calls 1

assert_expected_schemaFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…