Skip to content

Add date_histogram bucket aggregation support#6

Open
varun-st wants to merge 1 commit into
pr/histogram-bucketfrom
pr/date-histogram-bucket
Open

Add date_histogram bucket aggregation support#6
varun-st wants to merge 1 commit into
pr/histogram-bucketfrom
pr/date-histogram-bucket

Conversation

@varun-st

Copy link
Copy Markdown
Owner

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

Supports calendar intervals (month/day/hour) and fixed intervals (milliseconds) for date bucketing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant