Skip to content

Fix AutoDateHistogram RoundingInfo equals/hashCode to include all serialized fields#151156

Open
junhyeong9812 wants to merge 2 commits into
elastic:mainfrom
junhyeong9812:fix/auto-date-histogram-rounding-info-equals
Open

Fix AutoDateHistogram RoundingInfo equals/hashCode to include all serialized fields#151156
junhyeong9812 wants to merge 2 commits into
elastic:mainfrom
junhyeong9812:fix/auto-date-histogram-rounding-info-equals

Conversation

@junhyeong9812

Copy link
Copy Markdown

AutoDateHistogramAggregationBuilder.RoundingInfo serializes five fields in writeTo (rounding, roughEstimateDurationMillis, innerIntervals, unitAbbreviation, dateTimeUnit) but its equals()/hashCode() only consider three of them, omitting roughEstimateDurationMillis (a long) and unitAbbreviation (a String). Two RoundingInfo instances that differ only in one of those serialized fields therefore compare equal and share a hash code.

This includes both fields in equals() and hashCode() and adds a regression test. RoundingInfo equality also feeds into InternalAutoDateHistogram.BucketInfo, which compares RoundingInfo[] via deep equality, so this also makes reduce/result equality correct.

Closes #151155

RoundingInfo serializes roughEstimateDurationMillis and unitAbbreviation
but equals()/hashCode() omitted them, so instances differing only in those
fields compared equal. Include both and add a regression test. This also
fixes RoundingInfo[] deep equality used in InternalAutoDateHistogram.
@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team needs:triage Requires assignment of a team area label v9.5.0 labels Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team needs:triage Requires assignment of a team area label v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auto_date_histogram aggregation: RoundingInfo equals()/hashCode() omit serialized fields ("roughEstimateDurationMillis", "unitAbbreviation")

2 participants