mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 23:57:20 -04:00
Resolves #111842 This adds a conversion function that yields DATE_NANOS. Mostly this is straight forward. It is worth noting that when converting a millisecond date into a nanosecond date, the conversion function truncates it to 0 nanoseconds (i.e. first nanosecond of that millisecond). This is, of course, a bit of an assumption, but I don't have a better assumption we can make. I'd thought about adding a second, optional, parameter to control this behavior, but it's important that TO_DATE_NANOS extend AbstractConvertFunction, which itself extends UnaryScalarFunction, so that it will work correctly with union types. Also, it's unlikely the user will have any better guess than we do for filling in the nanoseconds. Making that assumption does, however, create some weirdness. Consider two comparisons: TO_DATETIME("2023-03-23T12:15:03.360103847") == TO_DATETIME("2023-03-23T12:15:03.360") will return true while TO_DATE_NANOS("2023-03-23T12:15:03.360103847") == TO_DATE_NANOS("2023-03-23T12:15:03.360") will return false. This is akin to casting between longs and doubles, where things may compare equal in one type that are not equal in the other. This seems fine, and I can't think of a better way to do it, but it's worth being aware of. --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> |
||
---|---|---|
.. | ||
appendix | ||
description | ||
examples | ||
kibana | ||
layout | ||
parameters | ||
signature | ||
types | ||
aggregation-functions.asciidoc | ||
binary.asciidoc | ||
cast.asciidoc | ||
conditional-functions-and-expressions.asciidoc | ||
date-time-functions.asciidoc | ||
grouping-functions.asciidoc | ||
in.asciidoc | ||
ip-functions.asciidoc | ||
like.asciidoc | ||
logical.asciidoc | ||
math-functions.asciidoc | ||
mv-functions.asciidoc | ||
operators.asciidoc | ||
predicates.asciidoc | ||
README.md | ||
rlike.asciidoc | ||
spatial-functions.asciidoc | ||
string-functions.asciidoc | ||
type-conversion-functions.asciidoc | ||
unary.asciidoc |
The files in these subdirectories are generated by ESQL's test suite:
description
- description of each function scraped from@FunctionInfo#description
examples
- examples of each function scraped from@FunctionInfo#examples
parameters
- description of each function's parameters scraped from@Param
signature
- railroad diagram of the syntax to invoke each functiontypes
- a table of each combination of support type for each parameter. These are generated from tests.layout
- a fully generated description for each functionkibana/definition
- function definitions for kibana's ESQL editorkibana/docs
- the inline docs for kibana
Most functions can use the generated docs generated in the layout
directory.
If we need something more custom for the function we can make a file in this
directory that can include::
any parts of the files above.
To regenerate the files for a function run its tests using gradle:
./gradlew :x-pack:plugin:esql:test -Dtests.class='*SinTests'
To regenerate the files for all functions run all of ESQL's tests using gradle:
./gradlew :x-pack:plugin:esql:test