-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESQL: allow DATE_PARSE to read the timezones #118603
Merged
elasticsearchmachine
merged 10 commits into
elastic:main
from
bpintea:fix/date_parse_tz
Dec 19, 2024
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b798118
Allow DATE_PARSE to read the TZ
bpintea 22c812a
Drop TZ param
bpintea cd85b6a
more tests
bpintea 6e7273b
drop redundant import
bpintea 4d44e80
Update docs/changelog/118603.yaml
bpintea 84d0e93
add cap guards
bpintea 01327a1
propagate dropping of TZ to unit test
bpintea 8bdd6c7
Merge branch 'main' into fix/date_parse_tz
bpintea babdb3e
Review comments
bpintea 083857f
Merge branch 'main' into fix/date_parse_tz
bpintea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 118603 | ||
summary: Allow DATE_PARSE to read the timezones | ||
area: ES|QL | ||
type: bug | ||
issues: | ||
- 117680 |
This file contains 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
21 changes: 7 additions & 14 deletions
21
...ated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseEvaluator.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,24 @@ public static Iterable<Object[]> parameters() { | |
new TestCaseSupplier.TypedData(new BytesRef("yyyy-MM-dd"), DataType.KEYWORD, "first"), | ||
new TestCaseSupplier.TypedData(new BytesRef("2023-05-05"), DataType.KEYWORD, "second") | ||
), | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0], zoneId=Z]", | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0]]", | ||
DataType.DATETIME, | ||
equalTo(1683244800000L) | ||
) | ||
), | ||
new TestCaseSupplier( | ||
"Timezoned Case", | ||
List.of(DataType.KEYWORD, DataType.KEYWORD), | ||
() -> new TestCaseSupplier.TestCase( | ||
List.of( | ||
new TestCaseSupplier.TypedData(new BytesRef("dd/MMM/yyyy:HH:mm:ss Z"), DataType.KEYWORD, "first"), | ||
new TestCaseSupplier.TypedData(new BytesRef("12/Jul/2022:10:24:10 +0900"), DataType.KEYWORD, "second") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we could randomize this a bit (only on the hour of course, no need to complicate it too much) |
||
), | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0]]", | ||
DataType.DATETIME, | ||
equalTo(1657589050000L) | ||
) | ||
), | ||
new TestCaseSupplier( | ||
"With Text", | ||
List.of(DataType.KEYWORD, DataType.TEXT), | ||
|
@@ -59,7 +72,7 @@ public static Iterable<Object[]> parameters() { | |
new TestCaseSupplier.TypedData(new BytesRef("yyyy-MM-dd"), DataType.KEYWORD, "first"), | ||
new TestCaseSupplier.TypedData(new BytesRef("2023-05-05"), DataType.TEXT, "second") | ||
), | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0], zoneId=Z]", | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0]]", | ||
DataType.DATETIME, | ||
equalTo(1683244800000L) | ||
) | ||
|
@@ -72,7 +85,7 @@ public static Iterable<Object[]> parameters() { | |
new TestCaseSupplier.TypedData(new BytesRef("yyyy-MM-dd"), DataType.TEXT, "first"), | ||
new TestCaseSupplier.TypedData(new BytesRef("2023-05-05"), DataType.TEXT, "second") | ||
), | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0], zoneId=Z]", | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0]]", | ||
DataType.DATETIME, | ||
equalTo(1683244800000L) | ||
) | ||
|
@@ -85,7 +98,7 @@ public static Iterable<Object[]> parameters() { | |
new TestCaseSupplier.TypedData(new BytesRef("yyyy-MM-dd"), DataType.TEXT, "first"), | ||
new TestCaseSupplier.TypedData(new BytesRef("2023-05-05"), DataType.KEYWORD, "second") | ||
), | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0], zoneId=Z]", | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0]]", | ||
DataType.DATETIME, | ||
equalTo(1683244800000L) | ||
) | ||
|
@@ -98,7 +111,7 @@ public static Iterable<Object[]> parameters() { | |
new TestCaseSupplier.TypedData(new BytesRef("2023-05-05"), DataType.KEYWORD, "second") | ||
|
||
), | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0], zoneId=Z]", | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0]]", | ||
DataType.DATETIME, | ||
is(nullValue()) | ||
).withWarning("Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.") | ||
|
@@ -118,7 +131,7 @@ public static Iterable<Object[]> parameters() { | |
new TestCaseSupplier.TypedData(new BytesRef("not a date"), DataType.KEYWORD, "second") | ||
|
||
), | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0], zoneId=Z]", | ||
"DateParseEvaluator[val=Attribute[channel=1], formatter=Attribute[channel=0]]", | ||
DataType.DATETIME, | ||
is(nullValue()) | ||
).withWarning("Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.") | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it would be good to have at least one test that crosses midnight (we could complicate it more with months/years/leap day but IMHO it's overkill)