Fix a DST error in date_histogram (backport of #52016) #52294
Merged
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.
When
date_histogram
attempts to optimize itself it for a particulartime zone it checks to see if the entire shard is within the same
"transition". Most time zone transition once every size months or
thereabouts so the optimization can usually kicks in.
But it crashes when you attempt feed it a time zone who's last DST
transition was before epoch. The reason for this is a little twisted:
before this patch it'd find the next and previous transitions in
milliseconds since epoch. Then it'd cast them to
Long
s and pass theminto the
DateFieldType
to check if the shard's contents were withinthe range. The trouble is they are then converted to
String
s which arethen parsed back to
Instant
s which are then convertd tolong
s. Andthe parser doesn't like most negative numbers. And everything before
epoch is negative.
This change removes the
long
->Long
->String
->Instant
->long
chain in favor ofpassing the
long
->Instant
->long
which avoids the fairly complexparsing code and handles a bunch of interesting edge cases around
epoch. And other edge cases around
date_nanos
.Closes #50265