Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
6 changes: 6 additions & 0 deletions docs/changelog/136548.yaml
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.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

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
Expand Up @@ -644,6 +644,46 @@ emp_no:integer | new_date:datetime | birth_date:datetime | bool:
10050 | 1958-05-21T00:00:00.000Z | 1958-05-21T00:00:00.000Z | true
;

evalDateParseWithTimezoneOption
required_capability: date_parse_options
row a = "10-10-2025" | eval b = date_parse("dd-mm-yyyy", a, {"time_zone":"Europe/Paris"}) | keep b;

b:datetime
2024-12-31T23:00:00.000Z
;

evalDateParseWithLocaleOption
required_capability: date_parse_options
row a = "10 septembre 2025" | eval b = date_parse("dd MMMM yyyy", a, {"locale":"fr"}) | keep b;

b:datetime
2025-09-10T00:00:00.000Z
;

evalDateParseWithLocaleAndTimezoneOption
required_capability: date_parse_options
row a = "10 septembre 2025" | eval b = date_parse("dd MMMM yyyy", a, {"locale":"fr","time_zone":"Europe/Paris"}) | keep b;

b:datetime
2025-09-09T22:00:00.000Z
;

evalDateParseDefaultFormatWithTimezoneOption
required_capability: date_parse_options
row a = "2023-02-01T12:15:55.000+01:00" | eval b = date_parse(a, {"time_zone":"Europe/Paris"}) | keep b;

b:datetime
2023-02-01T11:15:55.000Z
;

evalDateParseDefaultFormatWithLocaleOption
required_capability: date_parse_options
row a = "2023-02-01T12:15:55.000Z" | eval b = date_parse(a, {"locale":"fr"}) | keep b;

b:datetime
2023-02-01T12:15:55.000Z
;

dateFields
from employees | where emp_no == 10049 or emp_no == 10050
| eval year = date_extract("year", birth_date), month = date_extract("month_of_year", birth_date), day = date_extract("day_of_month", birth_date)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,11 @@ public enum Cap {
*/
FIX_FILTER_ORDINALS,

/**
* Optional options argument for DATE_PARSE
*/
DATE_PARSE_OPTIONS,

/**
* Allow multiple patterns for GROK command
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,12 +1042,20 @@ public interface BinaryBuilder<T> {
protected static <T extends Function> FunctionDefinition def(Class<T> function, TernaryBuilder<T> ctorRef, String... names) {
FunctionBuilder builder = (source, children, cfg) -> {
boolean hasMinimumTwo = OptionalArgument.class.isAssignableFrom(function);
if (hasMinimumTwo && (children.size() > 3 || children.size() < 2)) {
boolean hasMinimumOne = TwoOptionalArguments.class.isAssignableFrom(function);
if (hasMinimumOne && (children.size() > 3 || children.isEmpty())) {
throw new QlIllegalArgumentException("expects one, two or three arguments");
} else if (hasMinimumTwo && (children.size() > 3 || children.size() < 2)) {
throw new QlIllegalArgumentException("expects two or three arguments");
} else if (hasMinimumTwo == false && children.size() != 3) {
} else if (hasMinimumOne == false && hasMinimumTwo == false && children.size() != 3) {
throw new QlIllegalArgumentException("expects exactly three arguments");
}
return ctorRef.build(source, children.get(0), children.get(1), children.size() == 3 ? children.get(2) : null);
return ctorRef.build(
source,
children.get(0),
children.size() > 1 ? children.get(1) : null,
children.size() == 3 ? children.get(2) : null
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's.... fun. I don't really like it but it gets the job done. We can refine this later.

};
return def(function, builder, names);
}
Expand Down
Loading