eejbyfeldt opened a new pull request, #11093:
URL: https://github.com/apache/datafusion/pull/11093

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   Closes #. (TODO create ticket)
   
   ## Rationale for this change
   
   Currently the nullability of the value of the return type for the array_agg 
aggregate is wrong in two ways. Firstly the field inside the returned list is 
always nullable regardless of the input type and the actual list is only 
nullable depending on the input value. The correct behavior should be that the 
field in the list should depend on the input values nullabillity and the list 
field should not be nullable as the aggregate never returns null (it returns 
empty list instead).
   
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   
   In order to fix the nullability several changes are needed.
   
   1. For the logical expr it is currently hard coded that all aggregates 
return nullable values, this is changed to be something that looked up based on 
the actual functions used.  For UDAF we will need to add a new customization 
point in the future to handle this case.
   
   1. The return_type method for builtin aggregates got an additional argument 
`&[bool]` with the nullability of the the inputs. Without this is not possible 
to implement the function with correct nullability or array_agg.
   
   1. Helper methods ScalarValue::new_list and `array_into_list_array`  
currently always makes the field nullable. To make these more usable I added a 
nullable argument to them and renamed the existing version with a `_nullable` 
prefix.
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   
   Existing tests.
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   Yes, this will change the nullability of array_aggs. And it changes the 
interface for some public methods `ScalarValue::new_list`, 
`ScalarValue::new_list_from_iter` and `array_into_list_array` to take a 
`nullable: bool` argument.
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   


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