Add date_histogram bucket aggregation support#6
Open
varun-st wants to merge 1 commit into
Open
Conversation
Supports calendar intervals (month/day/hour) and fixed intervals (milliseconds) for date bucketing.
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 support for date_histogram bucket aggregation in the DSL Calcite plugin, enabling date-based bucketing for time-series data analysis.
Changes
Core Implementation
• DateHistogramGrouping: Converts date_histogram aggregations to Calcite SQL expressions
• Calendar intervals: FLOOR(timestamp TO MONTH/DAY/HOUR) for calendar-aware bucketing
• Fixed intervals: FLOOR(timestamp / interval_ms) * interval_ms for fixed-duration bucketing
• DateHistogramBucketShape: Adapter for DateHistogramAggregationBuilder
• Extracts field, calendar/fixed interval parameters
• Converts query results to InternalDateHistogram buckets
• Implements minDocCount=0 workaround for constructor assertion
Integration
• Registered DateHistogramBucketShape in AggregationRegistryFactory
• Made InternalDateHistogram constructor public for plugin access
Testing
• Unit tests: 12 tests covering DateHistogramGrouping and DateHistogramBucketShape
• Integration tests: 3 tests for calendar intervals, fixed intervals, and minDocCount filtering
Supported Parameters
• field: Date field to aggregate on
• calendar_interval: Calendar-aware intervals (1M, 1d, 1h, etc.)
• fixed_interval: Fixed-duration intervals (2h, 30m, 5000ms, etc.)
Not Supported (Future Work)
• time_zone: Timezone adjustment
• offset: Bucket boundary offset
• extended_bounds: Empty bucket generation
• hard_bounds: Bucket range limiting