alamb commented on code in PR #24276:
URL: https://github.com/apache/datafusion/pull/24276#discussion_r3791608020


##########
datafusion/expr-common/src/sort_properties.rs:
##########
@@ -89,35 +91,410 @@ impl SortProperties {
             }),
             (_, Self::Singleton) => *self,
             (Self::Ordered(lhs), Self::Ordered(rhs))
-                if lhs.descending != rhs.descending =>
+                if lhs.descending != rhs.descending
+                    && lhs.nulls_first == rhs.nulls_first =>
             {
                 *self
             }
             _ => Self::Unordered,
         }
     }
+    pub fn and(&self, rhs: &Self) -> Self {
+        // `descending == nulls_first` selects ASC NULLS LAST / DESC NULLS 
FIRST.
+        self.kleene(rhs, |opt| opt.descending == opt.nulls_first)
+    }
+
+    pub fn or(&self, rhs: &Self) -> Self {
+        // `descending != nulls_first` selects ASC NULLS FIRST / DESC NULLS 
LAST.
+        self.kleene(rhs, |opt| opt.descending != opt.nulls_first)
+    }
 
+    #[deprecated(
+        since = "55.0.0",
+        note = "`AND` and `OR` propagate orderings differently under 
three-valued logic; use `and` or `or`"
+    )]
     pub fn and_or(&self, rhs: &Self) -> Self {

Review Comment:
   
   I agree it doesn't seem like a good experience for downstream users to both 
change a method AND deprecate it. I would suggest either:
   1. Keep the old (incorrect) logic and mark it deprecated to minimize 
downstream changes required 
   2. Remove the method entirely. 
   
   I think in general, we have tried to leave methods deprecated for a while to 
help people migrate as described here - 
https://datafusion.apache.org/contributor-guide/api-health.html#when-to-make-breaking-api-changes
   
   Though with agents maybe it is less important
   



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