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


##########
datafusion/physical-expr/src/scalar_function.rs:
##########
@@ -251,10 +251,23 @@ pub fn out_ordering(
     func: &FuncMonotonicity,
     arg_orderings: &[SortProperties],
 ) -> SortProperties {
-    func.iter().zip(arg_orderings).fold(
+    arg_orderings.iter().enumerate().fold(
         SortProperties::Singleton,
-        |prev_sort, (item, arg)| {
-            let current_sort = func_order_in_one_dimension(item, arg);
+        |prev_sort, (index, arg)| {
+            let arg_monotonicity: Option<bool> = match func {
+                FuncMonotonicity::None => None,
+                FuncMonotonicity::Increasing => Some(true),
+                FuncMonotonicity::Decreasing => Some(false),
+                FuncMonotonicity::Mixed(inner_vec) => {

Review Comment:
   Maybe we could add something like
   
   ```rust
   enum Monotonicity {
     Increasing,
     Decreasing,
     Unknown,
   }
   ```
   
   And then represent `FuncMonotonicity::Mixed` with a `Vec<Monotonicity>`
   
   I would love to get a chance to pla around with it, but may not have time 
for a while



##########
datafusion/physical-expr/src/scalar_function.rs:
##########
@@ -251,10 +251,23 @@ pub fn out_ordering(
     func: &FuncMonotonicity,
     arg_orderings: &[SortProperties],
 ) -> SortProperties {
-    func.iter().zip(arg_orderings).fold(
+    arg_orderings.iter().enumerate().fold(
         SortProperties::Singleton,
-        |prev_sort, (item, arg)| {
-            let current_sort = func_order_in_one_dimension(item, arg);
+        |prev_sort, (index, arg)| {
+            let arg_monotonicity: Option<bool> = match func {
+                FuncMonotonicity::None => None,
+                FuncMonotonicity::Increasing => Some(true),
+                FuncMonotonicity::Decreasing => Some(false),
+                FuncMonotonicity::Mixed(inner_vec) => {

Review Comment:
   I agree the conversion feels confusing -- 
   
   > I do think that the conversion from FuncMonotonicity to Option<bool> is 
required in this function.
   > I tried a few different ways (without conversion) but it was resulting in 
really messy code.
   
   I would be interested in trying to help here as I think the major benefit of 
this change is to encapsulate the monotonicity calculations. I'll give it a look



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to