alamb commented on code in PR #10193:
URL: https://github.com/apache/datafusion/pull/10193#discussion_r1579753336
##########
datafusion/physical-expr/src/scalar_function.rs:
##########
@@ -142,25 +137,21 @@ impl PhysicalExpr for ScalarFunctionExpr {
}
fn evaluate(&self, batch: &RecordBatch) -> Result<ColumnarValue> {
- // evaluate the arguments, if there are no arguments we'll instead
pass in a null array
- // indicating the batch size (as a convention)
- let inputs = match self.args.is_empty() {
- // If the function supports zero argument, we pass in a null array
indicating the batch size.
- // This is for user-defined functions.
- // MakeArray support zero argument but has the different behavior
from the array with one null.
- true if self.supports_zero_argument && self.name != "make_array"
=> {
- vec![ColumnarValue::create_null_array(batch.num_rows())]
- }
- _ => self
- .args
- .iter()
- .map(|e| e.evaluate(batch))
- .collect::<Result<Vec<_>>>()?,
- };
+ let inputs = self
+ .args
+ .iter()
+ .map(|e| e.evaluate(batch))
+ .collect::<Result<Vec<_>>>()?;
// evaluate the function
match self.fun {
- ScalarFunctionDefinition::UDF(ref fun) => fun.invoke(&inputs),
+ ScalarFunctionDefinition::UDF(ref fun) => {
+ if fun.support_randomness() {
+ fun.invoke_no_args(batch.num_rows())
Review Comment:
I don't quite understand `support_randomness` was needed. I gave it a try
locally and I think we can avoid `support_randomness` like this:
https://github.com/jayzhan211/arrow-datafusion/pull/2
Let me know what you think
--
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]