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


##########
datafusion/physical-expr/src/equivalence/properties/walk.rs:
##########
@@ -328,6 +352,266 @@ mod tests {
     };
     use datafusion_expr::{ColumnarValue, Operator, Volatility, create_udf};
 
+    /// With `CAST(c AS DATE) = a`, the ordering `[a, c]` implies `[c]`, 
whether
+    /// the ordering or the equality comes first.
+    #[test]
+    fn implied_ordering_does_not_depend_on_call_order() -> Result<()> {
+        let schema = Arc::new(Schema::new(vec![
+            Field::new("a", DataType::Date32, true),
+            Field::new("c", DataType::Timestamp(TimeUnit::Nanosecond, None), 
true),
+        ]));
+        let [a, c] = ["a", "c"].map(|name| col(name, &schema).unwrap());
+        let cast_c = Arc::new(CastExpr::new_with_target_field(
+            Arc::clone(&c),
+            Arc::new(Field::new("c", DataType::Date32, true)),
+            None,
+        )) as Arc<dyn PhysicalExpr>;
+        let ordering =
+            [&a, &c].map(|expr| 
PhysicalSortExpr::new_default(Arc::clone(expr)));
+
+        let mut equality_first = 
EquivalenceProperties::new(Arc::clone(&schema));
+        equality_first.add_equal_conditions(Arc::clone(&cast_c), 
Arc::clone(&a))?;
+        equality_first.add_ordering(ordering.clone());
+
+        let mut ordering_first = 
EquivalenceProperties::new(Arc::clone(&schema));

Review Comment:
   Could we parameterize `implied_ordering_does_not_depend_on_call_order` over 
sort options? It would be useful to cover matching descending directions and 
verify that `[a DESC, c ASC]` does not imply global `[c ASC]` across distinct 
dates, with both equality/ordering insertion orders. The reported generated 
sweep already covers all four directions, so this would provide focused 
regression coverage.



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