-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Locale and timezone argument for date_parse #136548
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
base: main
Are you sure you want to change the base?
Changes from 10 commits
acc9837
e9ee7b8
104648b
0f39275
f3932ca
38a58cd
76dedf5
e12c332
f4e4518
f3187d8
435bd98
706c558
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 136548 | ||
summary: Locale and timezone argument for `date_parse` | ||
area: ES|QL | ||
type: enhancement | ||
issues: | ||
- 132487 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,7 +19,8 @@ protected DateParse createTestInstance() { | |||||||||||||||||||||||||||
Source source = randomSource(); | ||||||||||||||||||||||||||||
Expression first = randomChild(); | ||||||||||||||||||||||||||||
Expression second = randomBoolean() ? null : randomChild(); | ||||||||||||||||||||||||||||
return new DateParse(source, first, second); | ||||||||||||||||||||||||||||
Expression options = second != null && randomBoolean() ? randomChild() : null; | ||||||||||||||||||||||||||||
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. Can't we create the options even if "second" is null? |
||||||||||||||||||||||||||||
return new DateParse(source, first, second, options); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||
|
@@ -32,6 +33,11 @@ protected DateParse mutateInstance(DateParse instance) throws IOException { | |||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||
second = randomValueOtherThan(second, () -> randomBoolean() ? null : randomChild()); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
return new DateParse(source, first, second); | ||||||||||||||||||||||||||||
Expression options = instance.children().size() == 3 ? instance.children().get(2) : null; | ||||||||||||||||||||||||||||
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. We usually use a switch here, to only change 1 field. For example: Lines 26 to 38 in c40c5a6
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if (randomBoolean()) { | ||||||||||||||||||||||||||||
options = randomValueOtherThan(first, AbstractExpressionSerializationTests::randomChild); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
return new DateParse(source, first, second, options); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
} |
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.
This troubles me a bit. We're only allowing the options if the 2 previous parameters are present, even knowing that the format is optional too. That means, we're not allowing something like:
DATE_PARSE(date, {})
However, the SVG (docs) shows it correctly.
Now, I don't know if we did something like this before, or if we should allow it. Our function overriding detection is quite manual right now, to begin with. I would like if somebody else from the team can review this first.
The worse that could happen if we ship this is that:
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.
Good call... To me both allowing
DATE_PARSE(date, {})
or enforcing three params for options make sense, if we clearly communicate this to the user.Happy for someone else to make the call.
Uh oh!
There was an error while loading. Please reload this page.
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.
For reference,
DATE_PARSE(date_string, {\"time_zone\": \"Europe/Paris\",\"locale\":\"fr\"})
yieldsright now.
Your call of course, but if you feel comfortable with this behavior, we can get it in, then follow up later with supporting a more flexible calling pattern - we are lucky that the existing behavior on this PR is a subset of what could realistically be supported.
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.
I'm fine with closing this as-is. I would try to follow up soon though, as to not have the wrong docs there.
Btw, I was discussing this a bit, and I think we could make a working check here. Something like:
In general, having an optional param before a required is quite weird. But this is ""historical"" already, so here we are. For this special case, I think the logic to check it shouldn't be too complex, and we can manage to do it.
If there's some weird planning error after doing it, we can check it 👀