viirya commented on code in PR #27191:
URL: https://github.com/apache/datafusion/pull/27191#discussion_r4528359920


##########
datafusion/physical-expr/src/equivalence/properties/mod.rs:
##########
@@ -379,7 +379,8 @@ impl EquivalenceProperties {
         }
     }
 
-    /// Adds new orderings into the existing ordering equivalence class.
+    /// Adds new orderings into the existing ordering equivalence class, along
+    /// with the orderings they imply through known equalities.
     pub fn add_orderings(

Review Comment:
   Now that `add_orderings` derives implied orderings, a caller that adds an 
ordering before clearing per-partition constants keeps orderings that no longer 
hold. `RepartitionExec::eq_properties_helper` does this: it calls 
`add_ordering(merge key)` and then `clear_per_partition_constants()`. 
`SortPreservingMergeExec::compute_properties` clears first.
   
   With `k` a `Heterogeneous` constant, `CAST(c AS DATE) = a`, and merge key 
`[k, a, c]`, the repartition order leaves `ordering_satisfy([c])` true, 
although `[c]` doesn't hold once partitions with different `k` are merged. The 
SPM order gives false. Could `eq_properties_helper` clear the constants before 
`add_ordering`, the way SPM does? I don't see a SQL path to this today, because 
`UnionExec` drops equalities, so it mainly affects custom plans and any future 
source of per-partition constants.



-- 
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]

Reply via email to