-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Esql additional date format testing #120000
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
Changes from all commits
70413e7
c2cbced
26fe685
74dcf98
e8a6d96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -1007,6 +1007,17 @@ public static List<TypedDataSupplier> dateCases() { | |
return dateCases(Long.MIN_VALUE, Long.MAX_VALUE); | ||
} | ||
|
||
/** | ||
* Generate cases for {@link DataType#DATETIME}. | ||
* <p> | ||
* For multi-row parameters, see {@link MultiRowTestCaseSupplier#dateCases}. | ||
* </p> | ||
* Helper function for if you want to specify your min and max range as dates instead of longs. | ||
*/ | ||
public static List<TypedDataSupplier> dateCases(Instant min, Instant max) { | ||
return dateCases(min.toEpochMilli(), max.toEpochMilli()); | ||
} | ||
|
||
/** | ||
* Generate cases for {@link DataType#DATETIME}. | ||
* <p> | ||
|
@@ -1045,6 +1056,19 @@ public static List<TypedDataSupplier> dateCases(long min, long max) { | |
return cases; | ||
} | ||
|
||
/** | ||
* | ||
* @return randomized valid date formats | ||
*/ | ||
public static List<TypedDataSupplier> dateFormatCases() { | ||
return List.of( | ||
new TypedDataSupplier("<format as KEYWORD>", () -> new BytesRef(ESTestCase.randomDateFormatterPattern()), DataType.KEYWORD), | ||
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. This only generates the named formats, as far as I can tell. Would be good to write something that generates arbitrary format strings too, but I didn't see such a thing and this is still more coverage than we had. |
||
new TypedDataSupplier("<format as TEXT>", () -> new BytesRef(ESTestCase.randomDateFormatterPattern()), DataType.TEXT), | ||
new TypedDataSupplier("<format as KEYWORD>", () -> new BytesRef("yyyy"), DataType.KEYWORD), | ||
new TypedDataSupplier("<format as TEXT>", () -> new BytesRef("yyyy"), DataType.TEXT) | ||
); | ||
} | ||
|
||
/** | ||
* Generate cases for {@link DataType#DATE_NANOS}. | ||
* | ||
|
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.
The first positional argument can be a date, in the one parameter version of the function.
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.
It's quite a weird way to do it, but that's how the tests work.
We could, optionally, hack around this in the tests somehow. Or teach them about first position optional arguments. It's just that we don't have that many!