Add APPROX_PERCENTILE aggregation function#16041
Merged
Merged
Conversation
Add comprehensive implementation of the APPROX_PERCENTILE function for efficient percentile calculation using T-Digest algorithm: ## Core Components - TDigest algorithm implementation with memory optimization and reset functionality - Abstract base classes for both regular and grouped accumulator patterns - Support for both basic and weighted percentile calculations ## Features Added - Efficient quantile estimation with configurable compression - Memory usage tracking with RamUsageEstimator integration - Type-safe conversions for int, long, float, and double data types - Support for grouped aggregation operations - Reset functionality for memory reuse ## Performance Optimizations - Code structure improvements and method extraction for better maintainability - Reduced code duplication through inheritance hierarchy - Memory-efficient array management with TDigestBigArray 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ing and validation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements the APPROX_PERCENTILE aggregation function in IoTDB, providing efficient percentile calculation using the T-Digest algorithm. The implementation includes comprehensive support for both regular and weighted percentile calculations with memory optimizations.
- Adds T-Digest algorithm implementation with configurable compression and reset functionality
- Introduces abstract base classes for both regular and grouped accumulator patterns
- Provides support for all numeric data types (int, long, float, double) and grouped aggregations
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| common.thrift | Adds APPROX_PERCENTILE to TAggregationType enum |
| TableBuiltinAggregationFunction.java | Registers APPROX_PERCENTILE as builtin function |
| SqlConstant.java | Defines APPROX_PERCENTILE constant |
| AstBuilder.java | Adds validation for APPROX_PERCENTILE function arguments |
| TableMetadataImpl.java | Implements type validation and return type logic |
| TDigest.java | Core T-Digest algorithm implementation with serialization |
| TDigestBigArray.java | Memory-efficient array management for grouped operations |
| AbstractApproxPercentileAccumulator.java | Base class for single accumulator pattern |
| ApproxPercentileAccumulator.java | Regular percentile accumulator implementation |
| ApproxPercentileWithWeightAccumulator.java | Weighted percentile accumulator implementation |
| AbstractGroupedApproxPercentileAccumulator.java | Base class for grouped accumulator pattern |
| GroupedApproxPercentileAccumulator.java | Grouped regular percentile accumulator |
| GroupedApproxPercentileWithWeightAccumulator.java | Grouped weighted percentile accumulator |
| TDigestStateFactory.java | Factory for creating T-Digest state objects |
| AccumulatorFactory.java | Factory integration for accumulator creation |
| IoTDBTableAggregationIT.java | Integration tests for APPROX_PERCENTILE functionality |
JackieTien97
requested changes
Aug 18, 2025
…ndling and validation
JackieTien97
approved these changes
Aug 26, 2025
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.
Add comprehensive implementation of the APPROX_PERCENTILE function for efficient percentile calculation using T-Digest algorithm:
Core Components
Features Added
Performance Optimizations