pub fn update_ordering(
    node: ExprOrdering,
    sort_expr: &PhysicalSortExpr,
    equal_properties: &EquivalenceProperties,
    ordering_equal_properties: &OrderingEquivalenceProperties
) -> Result<Transformed<ExprOrdering>>
Expand description

Calculates the SortProperties of a given ExprOrdering node. The node is either a leaf node, or an intermediate node:

  • If it is a leaf node, the children states are None. We directly find the order of the node by looking at the given sort expression and equivalence properties if it is a Column leaf, or we mark it as unordered. In the case of a Literal leaf, we mark it as singleton so that it can cooperate with some ordered columns at the upper steps.
  • If it is an intermediate node, the children states matter. Each PhysicalExpr and operator has its own rules about how to propagate the children orderings. However, before the children order propagation, it is checked that whether the intermediate node can be directly matched with the sort expression. If there is a match, the sort expression emerges at that node immediately, discarding the order coming from the children.