fn sort_options_resolving_constant(
expr: Arc<dyn PhysicalExpr>,
only_monotonic: bool,
) -> Vec<PhysicalSortExpr>Expand description
Generates sort option variations for a given expression.
This function is used to handle constant columns in window operations. Since constant columns can be considered as having any ordering, we generate multiple sort options to explore different ordering possibilities.
§Parameters
expr: The physical expression to generate sort options foronly_monotonic: If false, generates all 4 possible sort options (ASC/DESC × NULLS FIRST/LAST). If true, generates only 2 options that preserve set monotonicity.
§When to use only_monotonic = false:
Use for PARTITION BY columns where we want to explore all possible orderings to find one that matches the existing data ordering.
§When to use only_monotonic = true:
Use for aggregate/window function arguments where set monotonicity needs to be preserved. Only generates ASC NULLS LAST and DESC NULLS FIRST because:
- Set monotonicity is broken if data has increasing order but nulls come first
- Set monotonicity is broken if data has decreasing order but nulls come last