adriangb commented on code in PR #19538:
URL: https://github.com/apache/datafusion/pull/19538#discussion_r2705741301
##########
datafusion/expr/src/udf.rs:
##########
@@ -846,6 +851,18 @@ pub trait ScalarUDFImpl: Debug + DynEq + DynHash + Send +
Sync {
fn documentation(&self) -> Option<&Documentation> {
None
}
+
+ /// Returns true if this function is trivial (cheap to evaluate).
Review Comment:
@lwwmanning and the Vortex team had a suggestion here that I like:
```rust
pub trait PhysicalExpr {
fn cost(&self) -> ExpressionCost;
...
}
#[non_exhaustive]
enum ExpressionCost {
/// Does not depend on the size or amount of data.
/// Examples of this are metadata only operations:
/// - `get_field`: extracts a field from a struct array, a cheap array
clone
/// - `arrow_typeof`: gets the type of an expression
/// - `count()` (without distinct): gets the number of rows (a metadata
only check)
Constant,
/// Depends on the size of the data in some way.
/// Examples of this are:
/// - Literal values (which get expanded / broadcast to the size of the
data)
/// - Operations applied to each row of the input
RowOriented,
}
```
The idea being that in the future we could do something like add a
`Cost(f64)` variant (not proposing this specifically) or otherwise expand /
alter this with less breaking changes.
--
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]