Skip to content

Conversation

@Sahitya0805
Copy link

@Sahitya0805 Sahitya0805 commented Feb 9, 2026

Fixes #18933.

This PR removes the strict schema alignment constraint from EquivalenceProperties::with_new_schema and OrderingEquivalenceClass::with_new_schema.

Previously, these methods required schemas to be 'aligned' (same number of columns, same types at each position), which made it difficult to update properties when schemas evolved (e.g., in projections or join operations).

Key changes:

  • EquivalenceProperties: Now matches columns by name and index using the expression rewriter. If a column is missing in the new schema, it is gracefully dropped from its equivalence class while keeping the rest of the group.
  • OrderingEquivalenceClass: Orderings are now truncated at the first column that cannot be mapped to the new schema, ensuring that prefix orderings are preserved.
  • Improved Robustness: This change allows DataFusion to maintain as much physical property information as possible through schema transformations (renames, appends, and removals).

Added regression tests to verify renames, appends, and column removals.

Introduces a new SortOptions struct with fluent builder methods
to eliminate boolean blindness in sort expressions.

Changes:
- Add SortOptions struct with desc(), asc(), nulls_first(), nulls_last()
- Add Expr::sort_by() method accepting SortOptions
- Keep existing Expr::sort() for backward compatibility
- Add test demonstrating both old and new APIs

Fixes apache#20227
Address review feedback to make the default values explicit
instead of hiding them behind Self::default().
@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates core Core DataFusion crate labels Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make EquivalenceProperties::new_with_schema not require aligned schema

1 participant