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


   ### Description
   Builds on top of #11104 and #10605 to add bitwise aggregator functions:
   
   |Function|Notes|Default|
   |--------|-----|-------|
   |`BIT_AND(expr)`|Performs a bitwise AND operation on all input 
values.|`null` if `druid.generic.useDefaultValueForNull=false`, otherwise `0`|
   |`BIT_OR(expr)`|Performs a bitwise OR operation on all input values.|`null` 
if `druid.generic.useDefaultValueForNull=false`, otherwise `0`|
   |`BIT_XOR(expr)`|Performs a bitwise XOR operation on all input 
values.|`null` if `druid.generic.useDefaultValueForNull=false`, otherwise `0`|
   
   In the process of adding this, I've also modified 
`ExpressionLambdaAggregatorFactory` to have an additional JSON property, 
   `initiallyNull`, which determines if the aggregator will produce a `null` 
value or `initialValue`/`initialCombineValue`. For example, an SQL compatible 
count aggregator would have `initiallyNull` set to `false` and have 
`initialValue` set to `0`, so that it would always return 0 even if no rows 
were aggregated, while a sum would have it set to `true` so that it would 
return `null` in the same case. For the buffer aggregator, this is tracked by 
setting a bit in the expression type byte which prefixes all of the serialized 
expressions, which is then cleared whenever the aggregate function is called. 
This change simplifies `ARRAY_AGG` since it was previously using a finalize 
expression to coerce empty results back to null, but now it can just naturally 
be initialized to null.
   
   This PR has:
   - [x] been self-reviewed.
   - [x] added documentation for new or modified features or behaviors.
   - [x] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [ ] 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