clintropolis opened a new pull request #11327:
URL: https://github.com/apache/druid/pull/11327


   ### Description
   This PR fixes the return type inference of several SQL operators which were 
incorrectly reporting their return type as not nullable, when in fact this was 
dependent on the arguments to the operator. A new method, 
`returnTypeCascadeNullable`, has been added to `OperatorConversions` builder 
type, which allows defining operators with a return type that is only nullable 
if any of the operands are nullable, which is many of them. I only evaluated 
all callers of `returnTypeNonNull`, and didn't look closely if some of the 
`returnTypeNullable` should be switched to this new method.
   
   This fixes bugs like in the test case added to `CalciteQueryTests`, which 
covers some of the functions which have been fixed and illustrates the fix 
(since these operators were previously marked as non-null, the count aggregator 
would be effectively translated to `count(*)`). I am unsure of what other bugs 
might have been happening besides this, but it is quite possible this PR fixes 
a handful of other issues with null handing in SQL compatible mode since some 
inappropriate optimizations might have been happening.
   
   Along the way, I also fixed null handling bugs in `repeat` which would've 
had a null pointer exception, and `timestamp_shift` which would ignore numeric 
nulls in SQL compatible mode and just shift.
   
   <hr>
   
   This PR has:
   - [x] been self-reviewed.
   - [x] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [x] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [x] been tested in a test Druid cluster.
   


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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to