elasticsearch/docs/reference/esql
Mark Tozzi 122e728820
[ESQL] Add TO_DATE_NANOS conversion function (#112150)
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>
2024-09-26 12:03:01 -04:00
..
functions [ESQL] Add TO_DATE_NANOS conversion function (#112150) 2024-09-26 12:03:01 -04:00
processing-commands [DOCS][ESQL] Include bucket in agg functions list (#112513) 2024-09-05 11:43:20 +02:00
source-commands ESQL: Validate unique plan attribute names (#110488) 2024-07-17 11:39:02 +02:00
esql-across-clusters.asciidoc [DOCS] Document CCS enrich with api-key based auth (#111682) 2024-08-07 19:37:16 +02:00
esql-apis.asciidoc (Doc+) Link API doc to parent object - part1 (#111951) 2024-08-20 14:58:18 -06:00
esql-async-query-api.asciidoc Remove esql version from docs (#108933) 2024-05-23 10:36:15 -04:00
esql-async-query-delete-api.asciidoc (Doc+) Link API doc to parent object - part1 (#111951) 2024-08-20 14:58:18 -06:00
esql-async-query-get-api.asciidoc Add ES|QL async query api docs (#104054) 2024-01-09 09:17:02 +00:00
esql-commands.asciidoc ESQL: INLINESTATS (#109583) 2024-07-24 17:16:37 -04:00
esql-enrich-data.asciidoc [DOCS] Refactor book-scoped variables in docs/reference/index.asciidoc (#107413) 2024-04-17 14:37:07 +02:00
esql-examples.asciidoc [DOCS] Small ES|QL improvements (#101877) 2023-11-07 17:24:59 +01:00
esql-functions-operators.asciidoc Introduce an IP functions group (#108304) 2024-05-06 13:43:30 +02:00
esql-get-started.asciidoc Revert "[DOCS] Remove ESQL demo env link from 8.14+ (#109562)" (#109579) 2024-06-11 17:04:37 +02:00
esql-kibana.asciidoc [DOCS] Update Using ESQL in Kibana doc (#108715) 2024-05-17 12:36:04 +02:00
esql-language.asciidoc ESQL: Remove OPTIONS clause in FROM command (#108692) 2024-05-15 18:15:02 -04:00
esql-limitations.asciidoc Union types documentation (#110183) 2024-07-16 12:06:19 +02:00
esql-multi-index.asciidoc ESQL: Fix for overzealous validation in case of invalid mapped fields (#111475) 2024-08-09 09:38:14 +02:00
esql-process-data-with-dissect-grok.asciidoc [DOCS] Empty keys for ES|QL DISSECT (#102632) 2023-12-11 11:23:27 +01:00
esql-query-api.asciidoc [DOCS] Fix response value in esql-query-api.asciidoc (#111882) 2024-08-14 16:26:54 +02:00
esql-rest.asciidoc docs for named and positional parameters (#111178) 2024-07-23 08:27:34 -04:00
esql-security-solution.asciidoc Update esql-security-solution.asciidoc (#104531) 2024-01-18 15:48:43 +01:00
esql-syntax.asciidoc ESQL: Add more time span units (#108300) 2024-05-08 08:51:02 -04:00
esql-using.asciidoc Union types documentation (#110183) 2024-07-16 12:06:19 +02:00
implicit-casting.asciidoc [DOCS] ES|QL implicit casting (#108618) 2024-05-15 09:07:09 -04:00
index.asciidoc [DOCS] ESQL goes GA (#108342) 2024-05-07 14:12:50 +02:00
metadata-fields.asciidoc Reapply "ESQL: Expose "_ignored" metadata field" (#108864) (#108871) 2024-05-22 07:06:04 -04:00
multivalued-fields.asciidoc Remove esql version from docs (#108933) 2024-05-23 10:36:15 -04:00
task-management.asciidoc [DOCS] One more round of restructuring the ES|QL documentation (#101340) 2023-10-26 10:57:05 +02:00