Add PercentileSmartTDigestAggregationFunction#8565
Merged
Jackie-Jiang merged 1 commit intoapache:masterfrom Apr 20, 2022
Merged
Add PercentileSmartTDigestAggregationFunction#8565Jackie-Jiang merged 1 commit intoapache:masterfrom
Jackie-Jiang merged 1 commit intoapache:masterfrom
Conversation
xiangfu0
approved these changes
Apr 19, 2022
| ExpressionContext firstArgument = arguments.get(0); | ||
| if (upperCaseFunctionName.startsWith("PERCENTILE")) { | ||
| String remainingFunctionName = upperCaseFunctionName.substring(10); | ||
| if (remainingFunctionName.equals("SMARTTDIGEST")) { |
Contributor
There was a problem hiding this comment.
case ignore match ?
Contributor
Author
There was a problem hiding this comment.
It's already canonicalized, so no need to ignore case
| public void aggregate(int length, AggregationResultHolder aggregationResultHolder, | ||
| Map<ExpressionContext, BlockValSet> blockValSetMap) { | ||
| BlockValSet blockValSet = blockValSetMap.get(_expression); | ||
| validateValueType(blockValSet); |
Contributor
There was a problem hiding this comment.
Doing this once (upon first call to aggregate) should be enough ?
Contributor
Author
There was a problem hiding this comment.
Yes, but because the aggregation function itself is stateless (shared across threads), we cannot add a variable to the function to track if it is the first call. The overhead of this call should be minimal. Once we enforce schema, we should be able to perform all these checks on the broker side
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
PercentileSmartTDigestAggregationFunctionwhich can automatically convert theDoubleArrayListtoTDigestif the list size grows too big to protect the servers from running out of memory. This conversion only applies to aggregation only queries, but not the group-by queries.By default, when the list size exceeds 100K, it will be converted to a TDigest with compression of 100.
The threshold and compression can be configured using the third argument (literal) of the function:
threshold: list size threshold to trigger the conversion, non-positive means never convert (default 100K)compression: compression of the converted TDigest (default 100)Example query:
SELECT PERCENTILE_SMART_TDIGEST(myCol, 95, 'threshold=10;compression=50') FROM myTableRelease Notes
Adds
PercentileSmartTDigestAggregationFunctionwhich automatically stores values in DoubleArrayList or TDigest based on the number of values