elasticsearch/docs/reference/esql/functions/signature
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
..
abs.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
acos.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
add.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
asin.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
atan.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
atan2.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
avg.svg ESQL: AVG aggregation tests and ignore complex surrogates (#110579) 2024-07-09 12:01:46 +02:00
bucket.svg ESQL: Rename AUTO_BUCKET to just BUCKET (#107197) 2024-04-10 12:21:08 +02:00
case.svg ESQL: Fix CASE when conditions are multivalued (#112401) 2024-09-10 02:32:19 +10:00
categorize.svg [ESQL] Add TO_DATE_NANOS conversion function (#112150) 2024-09-26 12:03:01 -04:00
cbrt.svg ESQL: CBRT function (#108574) 2024-05-15 16:50:15 +02:00
ceil.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
cidr_match.svg [ES|QL] Add/Modify annotations for operators for better doc generation (#108220) 2024-05-03 22:59:51 -04:00
coalesce.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
concat.svg [ES|QL] Remove variadic functions' optional args from the output of show functions (#106454) 2024-03-20 10:15:49 -04:00
cos.svg ESQL: Generate docs for the trig functions (#106891) 2024-03-29 12:24:31 -04:00
cosh.svg Update docs from code 2024-09-09 11:28:31 -04:00
count.svg ESQL: Add COUNT and COUNT_DISTINCT aggregation tests (#111409) 2024-07-30 03:07:15 +10:00
count_distinct.svg ESQL: Add COUNT and COUNT_DISTINCT aggregation tests (#111409) 2024-07-30 03:07:15 +10:00
date_diff.svg ESQL: add date_diff function (#104118) 2024-01-09 07:03:58 -05:00
date_extract.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
date_format.svg ES|QL: Improve support for TEXT fields in functions (#106810) 2024-03-27 08:47:09 -04:00
date_parse.svg ESQL: Tests for large concat and many evals (#100159) 2023-10-03 14:41:40 -04:00
date_trunc.svg ES|QL: Add unit tests and docs for DATE_TRUNC() (#107145) 2024-04-09 10:41:34 +02:00
div.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
e.svg ESQL: Standardize font used in railroad diagrams (#98897) 2023-08-26 14:19:47 -04:00
ends_with.svg [ES|QL] Annotate all ESQL functions (for SHOW FUNCTIONS) (#103686) 2024-01-11 10:15:30 +01:00
equals.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
exp.svg Add the EXP ES|QL function (#110879) 2024-07-16 16:36:01 +02:00
floor.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
from_base64.svg [ES|QL] Base64 decoding and encoding functions (#107390) 2024-04-15 18:39:26 -04:00
greater_than.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
greater_than_or_equal.svg ESQL: Add type tables for operators to docs (#103206) 2023-12-11 10:51:38 -05:00
greatest.svg ESQL: Tests for large concat and many evals (#100159) 2023-10-03 14:41:40 -04:00
ip_prefix.svg ESQL: Add ip_prefix function (#109070) 2024-05-29 10:23:45 -04:00
least.svg ESQL: Tests for large concat and many evals (#100159) 2023-10-03 14:41:40 -04:00
left.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
length.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
less_than.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
less_than_or_equal.svg ESQL: Add type tables for operators to docs (#103206) 2023-12-11 10:51:38 -05:00
locate.svg Add ES|QL Locate function (#106899) 2024-04-05 15:29:54 +02:00
log.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
log10.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
ltrim.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
max.svg ESQL: Add boolean support to Max and Min aggs (#110527) 2024-07-10 23:10:32 +10:00
median.svg ESQL: Added Median and MedianAbsoluteDeviation aggregations tests and kibana docs (#111231) 2024-07-26 22:11:01 +10:00
median_absolute_deviation.svg ESQL: Added Median and MedianAbsoluteDeviation aggregations tests and kibana docs (#111231) 2024-07-26 22:11:01 +10:00
min.svg ESQL: Add boolean support to Max and Min aggs (#110527) 2024-07-10 23:10:32 +10:00
mod.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
mul.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
mv_append.svg ES|QL: add MV_APPEND function (#107001) 2024-06-05 03:42:29 +10:00
mv_avg.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_concat.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_count.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_dedupe.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_first.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_last.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_max.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_median.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_median_absolute_deviation.svg ESQL: mv_median_absolute_deviation function (#112055) 2024-09-09 10:04:25 +02:00
mv_min.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_percentile.svg ESQL: Added mv_percentile function (#111749) 2024-08-20 15:29:19 +02:00
mv_pseries_weighted_sum.svg ESQL: Add MV_PSERIES_WEIGHTED_SUM for score calculations used by security solution (#109017) 2024-07-31 12:08:28 +02:00
mv_slice.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_sort.svg [ES|QL] Add mv_sort (#106095) 2024-03-13 12:04:12 -04:00
mv_sum.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
mv_zip.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
neg.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
not_equals.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
now.svg ES|QL: Add unit tests for now() function (#108498) 2024-05-10 14:28:19 +02:00
percentile.svg Added Percentile aggregation tests and Kibana docs (#111050) 2024-07-19 14:28:11 +02:00
pi.svg ESQL: Standardize font used in railroad diagrams (#98897) 2023-08-26 14:19:47 -04:00
pow.svg ESQL: Standardize font used in railroad diagrams (#98897) 2023-08-26 14:19:47 -04:00
qstr.svg [ESQL] Add TO_DATE_NANOS conversion function (#112150) 2024-09-26 12:03:01 -04:00
repeat.svg ESQL: add REPEAT string function (#109220) 2024-06-04 16:32:43 -05:00
replace.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
right.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
round.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
rtrim.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
signum.svg Add ES|QL signum function (#106866) 2024-04-04 09:48:35 +02:00
sin.svg ESQL: Generate docs for the trig functions (#106891) 2024-03-29 12:24:31 -04:00
sinh.svg Update docs from code 2024-09-09 11:28:31 -04:00
space.svg [ESQL] Add SPACE function (#112350) 2024-09-09 21:41:35 +10:00
split.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
sqrt.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
st_centroid_agg.svg ESQL: SpatialCentroid aggregation tests and docs (#111236) 2024-07-26 10:41:18 +02:00
st_contains.svg ESQL: Support ST_CONTAINS and ST_WITHIN (#106503) 2024-04-02 10:31:00 +02:00
st_disjoint.svg ESQL: Support ST_DISJOINT (#107007) 2024-04-08 12:26:26 +02:00
st_distance.svg ES|QL ST_DISTANCE Function (#108764) 2024-06-21 11:59:44 +02:00
st_intersects.svg Support ST_INTERSECTS between two geometry columns (#104907) 2024-03-19 17:58:37 +01:00
st_within.svg ESQL: Support ST_CONTAINS and ST_WITHIN (#106503) 2024-04-02 10:31:00 +02:00
st_x.svg Add two new OGC functions ST_X and ST_Y (#105768) 2024-03-06 11:19:54 +01:00
st_y.svg Add two new OGC functions ST_X and ST_Y (#105768) 2024-03-06 11:19:54 +01:00
starts_with.svg [ES|QL] Annotate all ESQL functions (for SHOW FUNCTIONS) (#103686) 2024-01-11 10:15:30 +01:00
sub.svg ESQL: Generate railroad diagrams for operators (#103143) 2023-12-08 09:24:34 -05:00
substring.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
sum.svg Added Sum aggregation tests and docs (#110984) 2024-07-22 21:43:58 +10:00
tan.svg ESQL: Generate docs for the trig functions (#106891) 2024-03-29 12:24:31 -04:00
tanh.svg Update docs from code 2024-09-09 11:28:31 -04:00
tau.svg ESQL: Standardize font used in railroad diagrams (#98897) 2023-08-26 14:19:47 -04:00
to_base64.svg [ES|QL] Base64 decoding and encoding functions (#107390) 2024-04-15 18:39:26 -04:00
to_boolean.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_cartesianpoint.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_cartesianshape.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_date_nanos.svg [ESQL] Add TO_DATE_NANOS conversion function (#112150) 2024-09-26 12:03:01 -04:00
to_dateperiod.svg [ES|QL] explicit cast a string literal to date_period and time_duration in arithmetic operations (#109193) 2024-09-09 14:56:43 -04:00
to_datetime.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_degrees.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_double.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_geopoint.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_geoshape.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_integer.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_ip.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_long.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_lower.svg ESQL: Add TO_UPPER and TO_LOWER functions (#104309) 2024-01-15 11:58:57 +01:00
to_radians.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_string.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_timeduration.svg [ES|QL] explicit cast a string literal to date_period and time_duration in arithmetic operations (#109193) 2024-09-09 14:56:43 -04:00
to_unsigned_long.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
to_upper.svg ESQL: Add TO_UPPER and TO_LOWER functions (#104309) 2024-01-15 11:58:57 +01:00
to_version.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
top.svg ESQL: Renamed TopList to Top (#110347) 2024-07-02 03:52:24 +10:00
trim.svg ESQL: Use generated docs for abs and acos (#106510) 2024-03-20 16:32:12 -04:00
values.svg ESQL: Add COUNT and COUNT_DISTINCT aggregation tests (#111409) 2024-07-30 03:07:15 +10:00
weighted_avg.svg ESQL: WEIGHTED_AVG aggregation tests and docs (#111449) 2024-07-31 00:42:23 +10:00