You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/10/14 10:38:12 UTC

Re: [PR] Minor: Move `Monotonicity` to `expr` crate [arrow-datafusion]

alamb commented on code in PR #7820:
URL: https://github.com/apache/arrow-datafusion/pull/7820#discussion_r1359317116


##########
datafusion/physical-expr/src/functions.rs:
##########
@@ -964,47 +957,6 @@ fn func_order_in_one_dimension(
     }
 }
 
-/// This function specifies monotonicity behaviors for built-in scalar functions.
-/// The list can be extended, only mathematical and datetime functions are
-/// considered for the initial implementation of this feature.
-pub fn get_func_monotonicity(fun: &BuiltinScalarFunction) -> Option<FuncMonotonicity> {

Review Comment:
   Can we please avoid a breaking api change by at least adding `pub use datafusion_expr::get_func_monotonicity` in this file? 
   
   However, since we are going to move this code anyways, what  would you think about putting this code as a method on `BuiltinScalarFunction` itself, so that it was easier to find
   
   Something like
   
   ```rust
   impl BuiltinScalarFunction {
     pub fn monotonicity(&self) -> Option<FuncMonotonicity> {
     ...
      }
   }
   ```
   
   And leaving the `get_func_monotonicity` as a deprecated function, perhaps like
   
   ```rust
   #[deprecated(message="use BuiltinScalarFunction::monotonicity")]
   pub fn get_func_monotonicity(fun: &BuiltinScalarFunction) -> Option<FuncMonotonicity> {
     fun.monotonicity()
   }
   ```
   
   



##########
datafusion/physical-expr/src/functions.rs:
##########
@@ -903,14 +904,6 @@ pub fn create_physical_fun(
     })
 }
 
-/// Monotonicity of the `ScalarFunctionExpr` with respect to its arguments.
-/// Each element of this vector corresponds to an argument and indicates whether
-/// the function's behavior is monotonic, or non-monotonic/unknown for that argument, namely:
-/// - `None` signifies unknown monotonicity or non-monotonicity.
-/// - `Some(true)` indicates that the function is monotonically increasing w.r.t. the argument in question.
-/// - Some(false) indicates that the function is monotonically decreasing w.r.t. the argument in question.
-pub type FuncMonotonicity = Vec<Option<bool>>;

Review Comment:
   Perhaps we can leave a `pub use datafusion_expr::FuncMonotonicty` in this module to ease backwards compatibility?



-- 
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-unsubscribe@arrow.apache.org

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