alamb commented on code in PR #23807:
URL: https://github.com/apache/datafusion/pull/23807#discussion_r3647826426
##########
datafusion/expr/src/udf.rs:
##########
@@ -981,10 +986,44 @@ pub trait ScalarUDFImpl: Debug + DynEq + DynHash + Send +
Sync + Any {
/// the input ordering.
///
/// For example, `concat(a || b)` preserves lexicographical ordering, but
`abs(a)` does not.
+ ///
+ /// This is a *non-strict* (monotone) property: distinct inputs may map to
+ /// equal outputs. See [`Self::strictly_order_preserving`] for a related
+ /// strict property and [`ExprProperties::strictly_order_preserving`] for
+ /// an explanation of the difference.
fn preserves_lex_ordering(&self, _inputs: &[ExprProperties]) ->
Result<bool> {
Ok(false)
}
+ /// Returns true if the function is strictly order-preserving with respect
Review Comment:
How is this related to the output_ordering method? I am wondering if we can
extend that rather tan introduce a new method
https://docs.rs/datafusion/latest/datafusion/logical_expr/trait.ScalarUDFImpl.html#method.output_ordering
##########
datafusion/expr/src/udf.rs:
##########
@@ -981,10 +986,44 @@ pub trait ScalarUDFImpl: Debug + DynEq + DynHash + Send +
Sync + Any {
/// the input ordering.
///
/// For example, `concat(a || b)` preserves lexicographical ordering, but
`abs(a)` does not.
+ ///
+ /// This is a *non-strict* (monotone) property: distinct inputs may map to
+ /// equal outputs. See [`Self::strictly_order_preserving`] for a related
+ /// strict property and [`ExprProperties::strictly_order_preserving`] for
+ /// an explanation of the difference.
fn preserves_lex_ordering(&self, _inputs: &[ExprProperties]) ->
Result<bool> {
Ok(false)
}
+ /// Returns true if the function is strictly order-preserving with respect
+ /// to its `Ordered` inputs: assuming those inputs advance simultaneously
+ /// (component-wise, i.e. all of them are sorted in the data), the output
+ /// is ordered in the same direction, equal outputs can only result from
+ /// equal values of those inputs (i.e. the mapping is one-to-one), and
+ /// nulls map to nulls.
+ ///
+ /// i.e. setting this to true means that `a.cmp(b) == f(a).cmp(f(b))`
+ ///
+ /// This is not simply a stricter [`Self::preserves_lex_ordering`] — the
+ /// two properties also assume different input orderings, and with
+ /// multiple ordered inputs neither implies the other. Monotone but
Review Comment:
It would have helped me to move these examples up to the top of the docs
##########
datafusion/ffi/src/expr/expr_properties.rs:
##########
@@ -54,6 +54,9 @@ impl TryFrom<FFI_ExprProperties> for ExprProperties {
sort_properties,
range,
preserves_lex_ordering: value.preserves_lex_ordering,
+ // Not carried over the FFI boundary (it would break the ABI);
+ // stay conservative.
+ strictly_order_preserving: false,
Review Comment:
cc @timsaucer
--
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]