Dandandan commented on a change in pull request #303:
URL: https://github.com/apache/arrow-datafusion/pull/303#discussion_r630297583



##########
File path: datafusion/src/physical_plan/functions.rs
##########
@@ -1373,20 +1370,26 @@ impl PhysicalExpr for ScalarFunctionExpr {
     }
 
     fn evaluate(&self, batch: &RecordBatch) -> Result<ColumnarValue> {
-        // evaluate the arguments
-        let inputs = self
-            .args
-            .iter()
-            .map(|e| e.evaluate(batch))
-            .collect::<Result<Vec<_>>>()?;
+        // evaluate the arguments, if there are no arguments we'll instead 
pass in a null array of
+        // batch size (as a convention)
+        let inputs = match self.args.len() {
+            0 => vec![ColumnarValue::Array(Arc::new(NullArray::new(

Review comment:
       Good call @jorgecarleitao - I feel both approaches are a bit 
"workarounds" to the issue of not having something in design for zero-arguments 
functions.
   
   I feel what would be "cleaner":
   * passing a `usize` argument for the batch size (`so you don't have to do 
`args[0].num_rows()` or something like that but use the length anywhere. This 
might break some stuff(?)
   * having another node for zero-argument functions. This might duplicate some 
stuff(?)




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to