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


   ### Description
   This PR adds `STRING_AGG`, which is sort of like `ARRAY_AGG` added in #11157 
but it ignores null values, with an `ARRAY_TO_STRING` function on the output 
array to turn it into a string value.
   
   example:
   ```sql
   SELECT STRING_AGG(l1, '-'), STRING_AGG(DISTINCT l1, ',') FROM numfoo
   ```
   output:
   ```
   ["7-325323-0-0-0-0", "0,7,325323"]
   ```
   
   |Function|Notes|Default|
   |--------|-----|-------|
   |`STRING_AGG(expr, separator, [size])`|Collects all values of `expr` into a 
single STRING, ignoring null values. Each value is joined by the `separator` 
which must be a literal STRING. An optional `size` in bytes can be supplied to 
limit aggregation size (default of 1024 bytes). If the aggregated string grows 
larger than the maximum size in bytes, the query will fail. Use of `ORDER BY` 
within the `STRING_AGG` expression is not currently supported, and the ordering 
of results within the output string may vary depending on processing 
order.|`null` if `druid.generic.useDefaultValueForNull=false`, otherwise `''`|
   |`STRING_AGG(DISTINCT expr, separator, [size])`|Collects all distinct values 
of `expr` into a single STRING, ignoring null values. Each value is joined by 
the `separator` which must be a literal STRING. An optional `size` in bytes can 
be supplied to limit aggregation size (default of 1024 bytes). If the 
aggregated string grows larger than the maximum size in bytes, the query will 
fail. Use of `ORDER BY` within the `STRING_AGG` expression is not currently 
supported, and the ordering of results within the output string may vary 
depending on processing order.|`null` if 
`druid.generic.useDefaultValueForNull=false`, otherwise `''`|
   
   Like `ARRAY_AGG` this is an expression aggregator, so is not well optimized, 
but will fill in the gaps for now.
   
   This PR has:
   - [ ] been self-reviewed.
      - [ ] using the [concurrency 
checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md)
 (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] 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.
   - [ ] added integration tests.
   - [ ] 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