LiaCastaneda commented on PR #21679:
URL: https://github.com/apache/datafusion/pull/21679#issuecomment-4282634185

   > @LiaCastaneda For invoking the current version would indeed work for 
reduce/list_reduce, but the problem is during planning as the accumulator 
parameter datatype of the merge lambda depends on the lambda itself, and the 
parameter of finish lambda depends on the output of the merge lambda, which is 
not possible to express with the current single step lambda_parameters
   
   I understand, thanks for explaining, so the issue with these kinds of 
lambdas is that we can't always rely on inferring the type from the init value. 
looks like we have two issues with type inference:
   
   the following  query would break because we don't know the init type:
   `SELECT reduce(array(1, 2, 3), [], (acc, x) -> array_append(acc, x), acc -> 
array_length(acc))`
   ^ that would be fixed by requiring the user to provide a valid typed value, 
same as other engines.
   
   And also, iiuc we also need a solution to handle cases like:
   `SELECT reduce(array(1, 2, 3), 0, (acc, x) -> cast(acc as varchar), acc -> 
upper(acc))`
   because the init type is different from the finish lambda's input type, 
which is where the multistep solution you mention help.


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

Reply via email to