Fixed rewrite of time zone without DST (#54398)
We try to rewrite time zones to fixed offsets in the date histogram aggregation if the data in the shard is within a single transition. However this optimization is not applied on time zones that don't apply daylight saving changes but had some random transitions in the past (e.g. Australia/Brisbane or Asia/Katmandu). This changes fixes the rewrite of such time zones to fixed offsets.
This commit is contained in:
parent
4b4fbc160d
commit
12cfdc24b0
|
@ -479,7 +479,7 @@ public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuil
|
||||||
if (nextOffsetTransition != null) {
|
if (nextOffsetTransition != null) {
|
||||||
nextTransition = nextOffsetTransition.getInstant().toEpochMilli();
|
nextTransition = nextOffsetTransition.getInstant().toEpochMilli();
|
||||||
} else {
|
} else {
|
||||||
nextTransition = instant.toEpochMilli();
|
nextTransition = Long.MAX_VALUE; // fixed time-zone after prevTransition
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need all not only values but also rounded values to be within
|
// We need all not only values but also rounded values to be within
|
||||||
|
|
|
@ -170,6 +170,18 @@ public class DateHistogramTests extends BaseAggregationTestCase<DateHistogramAgg
|
||||||
assertSame(tz, builder.rewriteTimeZone(shardContextThatDoesntCross));
|
assertSame(tz, builder.rewriteTimeZone(shardContextThatDoesntCross));
|
||||||
assertSame(tz, builder.rewriteTimeZone(shardContextThatCrosses));
|
assertSame(tz, builder.rewriteTimeZone(shardContextThatCrosses));
|
||||||
|
|
||||||
|
// timeZone without DST => always rewrite
|
||||||
|
tz = ZoneId.of("Australia/Brisbane");
|
||||||
|
builder.timeZone(tz);
|
||||||
|
assertSame(ZoneOffset.ofHours(10), builder.rewriteTimeZone(shardContextThatDoesntCross));
|
||||||
|
assertSame(ZoneOffset.ofHours(10), builder.rewriteTimeZone(shardContextThatCrosses));
|
||||||
|
|
||||||
|
// another timeZone without DST => always rewrite
|
||||||
|
tz = ZoneId.of("Asia/Katmandu");
|
||||||
|
builder.timeZone(tz);
|
||||||
|
assertSame(ZoneOffset.ofHoursMinutes(5, 45), builder.rewriteTimeZone(shardContextThatDoesntCross));
|
||||||
|
assertSame(ZoneOffset.ofHoursMinutes(5, 45), builder.rewriteTimeZone(shardContextThatCrosses));
|
||||||
|
|
||||||
// daylight-saving-times => rewrite if doesn't cross
|
// daylight-saving-times => rewrite if doesn't cross
|
||||||
tz = ZoneId.of("Europe/Paris");
|
tz = ZoneId.of("Europe/Paris");
|
||||||
builder.timeZone(tz);
|
builder.timeZone(tz);
|
||||||
|
|
Loading…
Reference in New Issue