diff --git a/docs/changelog/117939.yaml b/docs/changelog/117939.yaml new file mode 100644 index 000000000000..d41111f099f9 --- /dev/null +++ b/docs/changelog/117939.yaml @@ -0,0 +1,5 @@ +pr: 117939 +summary: Adding default endpoint for Elastic Rerank +area: Machine Learning +type: enhancement +issues: [] diff --git a/docs/changelog/118027.yaml b/docs/changelog/118027.yaml new file mode 100644 index 000000000000..161c156b56a6 --- /dev/null +++ b/docs/changelog/118027.yaml @@ -0,0 +1,6 @@ +pr: 118027 +summary: Esql compare nanos and millis +area: ES|QL +type: enhancement +issues: + - 116281 diff --git a/docs/reference/esql/functions/kibana/definition/equals.json b/docs/reference/esql/functions/kibana/definition/equals.json index 885d949f4b20..40f3d54ba597 100644 --- a/docs/reference/esql/functions/kibana/definition/equals.json +++ b/docs/reference/esql/functions/kibana/definition/equals.json @@ -77,6 +77,42 @@ "variadic" : false, "returnType" : "boolean" }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, { "params" : [ { diff --git a/docs/reference/esql/functions/kibana/definition/greater_than.json b/docs/reference/esql/functions/kibana/definition/greater_than.json index cf6e30a0a454..ea2c0fb1212c 100644 --- a/docs/reference/esql/functions/kibana/definition/greater_than.json +++ b/docs/reference/esql/functions/kibana/definition/greater_than.json @@ -23,6 +23,42 @@ "variadic" : false, "returnType" : "boolean" }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, { "params" : [ { diff --git a/docs/reference/esql/functions/kibana/definition/greater_than_or_equal.json b/docs/reference/esql/functions/kibana/definition/greater_than_or_equal.json index 2535c68af6ac..7e1feb37e87b 100644 --- a/docs/reference/esql/functions/kibana/definition/greater_than_or_equal.json +++ b/docs/reference/esql/functions/kibana/definition/greater_than_or_equal.json @@ -23,6 +23,42 @@ "variadic" : false, "returnType" : "boolean" }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, { "params" : [ { diff --git a/docs/reference/esql/functions/kibana/definition/less_than.json b/docs/reference/esql/functions/kibana/definition/less_than.json index a73754d200d4..71aae4d759ec 100644 --- a/docs/reference/esql/functions/kibana/definition/less_than.json +++ b/docs/reference/esql/functions/kibana/definition/less_than.json @@ -23,6 +23,42 @@ "variadic" : false, "returnType" : "boolean" }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, { "params" : [ { diff --git a/docs/reference/esql/functions/kibana/definition/less_than_or_equal.json b/docs/reference/esql/functions/kibana/definition/less_than_or_equal.json index 7af477db32a3..f119b7ab2eb1 100644 --- a/docs/reference/esql/functions/kibana/definition/less_than_or_equal.json +++ b/docs/reference/esql/functions/kibana/definition/less_than_or_equal.json @@ -23,6 +23,42 @@ "variadic" : false, "returnType" : "boolean" }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, { "params" : [ { diff --git a/docs/reference/esql/functions/kibana/definition/not_equals.json b/docs/reference/esql/functions/kibana/definition/not_equals.json index 24f31115cbc3..d35a5b43ec23 100644 --- a/docs/reference/esql/functions/kibana/definition/not_equals.json +++ b/docs/reference/esql/functions/kibana/definition/not_equals.json @@ -77,6 +77,42 @@ "variadic" : false, "returnType" : "boolean" }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, + { + "params" : [ + { + "name" : "lhs", + "type" : "date_nanos", + "optional" : false, + "description" : "An expression." + }, + { + "name" : "rhs", + "type" : "date", + "optional" : false, + "description" : "An expression." + } + ], + "variadic" : false, + "returnType" : "boolean" + }, { "params" : [ { diff --git a/docs/reference/esql/functions/types/equals.asciidoc b/docs/reference/esql/functions/types/equals.asciidoc index 8d48b7ebf084..1bb8bf2122b3 100644 --- a/docs/reference/esql/functions/types/equals.asciidoc +++ b/docs/reference/esql/functions/types/equals.asciidoc @@ -9,6 +9,8 @@ boolean | boolean | boolean cartesian_point | cartesian_point | boolean cartesian_shape | cartesian_shape | boolean date | date | boolean +date | date_nanos | boolean +date_nanos | date | boolean date_nanos | date_nanos | boolean double | double | boolean double | integer | boolean diff --git a/docs/reference/esql/functions/types/greater_than.asciidoc b/docs/reference/esql/functions/types/greater_than.asciidoc index 8000fd34c850..39253ac445f4 100644 --- a/docs/reference/esql/functions/types/greater_than.asciidoc +++ b/docs/reference/esql/functions/types/greater_than.asciidoc @@ -6,6 +6,8 @@ |=== lhs | rhs | result date | date | boolean +date | date_nanos | boolean +date_nanos | date | boolean date_nanos | date_nanos | boolean double | double | boolean double | integer | boolean diff --git a/docs/reference/esql/functions/types/greater_than_or_equal.asciidoc b/docs/reference/esql/functions/types/greater_than_or_equal.asciidoc index 8000fd34c850..39253ac445f4 100644 --- a/docs/reference/esql/functions/types/greater_than_or_equal.asciidoc +++ b/docs/reference/esql/functions/types/greater_than_or_equal.asciidoc @@ -6,6 +6,8 @@ |=== lhs | rhs | result date | date | boolean +date | date_nanos | boolean +date_nanos | date | boolean date_nanos | date_nanos | boolean double | double | boolean double | integer | boolean diff --git a/docs/reference/esql/functions/types/less_than.asciidoc b/docs/reference/esql/functions/types/less_than.asciidoc index 8000fd34c850..39253ac445f4 100644 --- a/docs/reference/esql/functions/types/less_than.asciidoc +++ b/docs/reference/esql/functions/types/less_than.asciidoc @@ -6,6 +6,8 @@ |=== lhs | rhs | result date | date | boolean +date | date_nanos | boolean +date_nanos | date | boolean date_nanos | date_nanos | boolean double | double | boolean double | integer | boolean diff --git a/docs/reference/esql/functions/types/less_than_or_equal.asciidoc b/docs/reference/esql/functions/types/less_than_or_equal.asciidoc index 8000fd34c850..39253ac445f4 100644 --- a/docs/reference/esql/functions/types/less_than_or_equal.asciidoc +++ b/docs/reference/esql/functions/types/less_than_or_equal.asciidoc @@ -6,6 +6,8 @@ |=== lhs | rhs | result date | date | boolean +date | date_nanos | boolean +date_nanos | date | boolean date_nanos | date_nanos | boolean double | double | boolean double | integer | boolean diff --git a/docs/reference/esql/functions/types/not_equals.asciidoc b/docs/reference/esql/functions/types/not_equals.asciidoc index 8d48b7ebf084..1bb8bf2122b3 100644 --- a/docs/reference/esql/functions/types/not_equals.asciidoc +++ b/docs/reference/esql/functions/types/not_equals.asciidoc @@ -9,6 +9,8 @@ boolean | boolean | boolean cartesian_point | cartesian_point | boolean cartesian_shape | cartesian_shape | boolean date | date | boolean +date | date_nanos | boolean +date_nanos | date | boolean date_nanos | date_nanos | boolean double | double | boolean double | integer | boolean diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java index 9e31fdde4330..9dc3478994f1 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java @@ -13,7 +13,6 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.synonym.SynonymFilter; import org.apache.lucene.analysis.synonym.SynonymMap; -import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -152,15 +151,6 @@ public static SynonymsSource fromSettings(Settings settings) { super(name, settings); this.settings = settings; - if (settings.get("ignore_case") != null) { - DEPRECATION_LOGGER.warn( - DeprecationCategory.ANALYSIS, - "synonym_ignore_case_option", - "The ignore_case option on the synonym_graph filter is deprecated. " - + "Instead, insert a lowercase filter in the filter chain before the synonym_graph filter." - ); - } - this.synonymsSource = SynonymsSource.fromSettings(settings); this.expand = settings.getAsBoolean("expand", true); this.format = settings.get("format", ""); diff --git a/muted-tests.yml b/muted-tests.yml index 2b4cc3991a25..fb2fea908ef9 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -251,6 +251,15 @@ tests: - class: org.elasticsearch.packaging.test.ArchiveTests method: test41AutoconfigurationNotTriggeredWhenNodeCannotContainData issue: https://github.com/elastic/elasticsearch/issues/118110 +- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT + method: test {lookup-join.LookupMessageFromIndexKeepReordered SYNC} + issue: https://github.com/elastic/elasticsearch/issues/118150 +- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT + method: test {lookup-join.LookupMessageFromIndexKeepReordered ASYNC} + issue: https://github.com/elastic/elasticsearch/issues/118151 +- class: org.elasticsearch.xpack.remotecluster.CrossClusterEsqlRCS2UnavailableRemotesIT + method: testEsqlRcs2UnavailableRemoteScenarios + issue: https://github.com/elastic/elasticsearch/issues/117419 # Examples: # diff --git a/server/src/main/java/org/elasticsearch/common/time/DateUtils.java b/server/src/main/java/org/elasticsearch/common/time/DateUtils.java index 9f642734ba83..72306b6ed675 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateUtils.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateUtils.java @@ -293,6 +293,37 @@ public static long toMilliSeconds(long nanoSecondsSinceEpoch) { return nanoSecondsSinceEpoch / 1_000_000; } + /** + * Compare an epoch nanosecond date (such as returned by {@link DateUtils#toLong} + * to an epoch millisecond date (such as returned by {@link Instant#toEpochMilli()}}. + *
+ * NB: This function does not implement {@link java.util.Comparator} in
+ * order to avoid performance costs of autoboxing the input longs.
+ *
+ * @param nanos Epoch date represented as a long number of nanoseconds.
+ * Note that Elasticsearch does not support nanosecond dates
+ * before Epoch, so this number should never be negative.
+ * @param millis Epoch date represented as a long number of milliseconds.
+ * This parameter does not have to be constrained to the
+ * range of long nanosecond dates.
+ * @return -1 if the nanosecond date is before the millisecond date,
+ * 0 if the two dates represent the same instant,
+ * 1 if the nanosecond date is after the millisecond date
+ */
+ public static int compareNanosToMillis(long nanos, long millis) {
+ assert nanos >= 0;
+ if (millis < 0) {
+ return 1;
+ }
+ if (millis > MAX_NANOSECOND_IN_MILLIS) {
+ return -1;
+ }
+ // This can't overflow, because we know millis is between 0 and MAX_NANOSECOND_IN_MILLIS,
+ // and MAX_NANOSECOND_IN_MILLIS * 1_000_000 doesn't overflow.
+ long diff = nanos - (millis * 1_000_000);
+ return diff == 0 ? 0 : diff < 0 ? -1 : 1;
+ }
+
/**
* Rounds the given utc milliseconds sicne the epoch down to the next unit millis
*
diff --git a/server/src/test/java/org/elasticsearch/common/time/DateUtilsTests.java b/server/src/test/java/org/elasticsearch/common/time/DateUtilsTests.java
index 2dd0a2801305..e15bbbf75a52 100644
--- a/server/src/test/java/org/elasticsearch/common/time/DateUtilsTests.java
+++ b/server/src/test/java/org/elasticsearch/common/time/DateUtilsTests.java
@@ -20,7 +20,11 @@
import java.time.ZonedDateTime;
import java.time.temporal.ChronoField;
+import static org.elasticsearch.common.time.DateUtils.MAX_MILLIS_BEFORE_MINUS_9999;
+import static org.elasticsearch.common.time.DateUtils.MAX_NANOSECOND_INSTANT;
+import static org.elasticsearch.common.time.DateUtils.MAX_NANOSECOND_IN_MILLIS;
import static org.elasticsearch.common.time.DateUtils.clampToNanosRange;
+import static org.elasticsearch.common.time.DateUtils.compareNanosToMillis;
import static org.elasticsearch.common.time.DateUtils.toInstant;
import static org.elasticsearch.common.time.DateUtils.toLong;
import static org.elasticsearch.common.time.DateUtils.toMilliSeconds;
@@ -28,9 +32,45 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThan;
public class DateUtilsTests extends ESTestCase {
+ public void testCompareNanosToMillis() {
+ assertThat(MAX_NANOSECOND_IN_MILLIS * 1_000_000, lessThan(Long.MAX_VALUE));
+
+ assertThat(compareNanosToMillis(toLong(Instant.EPOCH), Instant.EPOCH.toEpochMilli()), is(0));
+
+ // This should be 1, because the millisecond version should truncate a bit
+ assertThat(compareNanosToMillis(toLong(MAX_NANOSECOND_INSTANT), MAX_NANOSECOND_INSTANT.toEpochMilli()), is(1));
+
+ assertThat(compareNanosToMillis(toLong(MAX_NANOSECOND_INSTANT), -1000), is(1));
+ // millis before epoch
+ assertCompareInstants(
+ randomInstantBetween(Instant.EPOCH, MAX_NANOSECOND_INSTANT),
+ randomInstantBetween(Instant.ofEpochMilli(MAX_MILLIS_BEFORE_MINUS_9999), Instant.ofEpochMilli(-1L))
+ );
+
+ // millis after nanos range
+ assertCompareInstants(
+ randomInstantBetween(Instant.EPOCH, MAX_NANOSECOND_INSTANT),
+ randomInstantBetween(MAX_NANOSECOND_INSTANT.plusMillis(1), Instant.ofEpochMilli(Long.MAX_VALUE))
+ );
+
+ // both in range
+ Instant nanos = randomInstantBetween(Instant.EPOCH, MAX_NANOSECOND_INSTANT);
+ Instant millis = randomInstantBetween(Instant.EPOCH, MAX_NANOSECOND_INSTANT);
+
+ assertCompareInstants(nanos, millis);
+ }
+
+ /**
+ * check that compareNanosToMillis is consistent with Instant#compare.
+ */
+ private void assertCompareInstants(Instant nanos, Instant millis) {
+ assertThat(compareNanosToMillis(toLong(nanos), millis.toEpochMilli()), equalTo(nanos.compareTo(millis)));
+ }
+
public void testInstantToLong() {
assertThat(toLong(Instant.EPOCH), is(0L));
diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java
index d6715a932c07..ec9af33dd669 100644
--- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java
+++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java
@@ -726,7 +726,7 @@ public static Literal randomLiteral(DataType type) {
case UNSIGNED_LONG, LONG, COUNTER_LONG -> randomLong();
case DATE_PERIOD -> Period.of(randomIntBetween(-1000, 1000), randomIntBetween(-13, 13), randomIntBetween(-32, 32));
case DATETIME -> randomMillisUpToYear9999();
- case DATE_NANOS -> randomLong();
+ case DATE_NANOS -> randomLongBetween(0, Long.MAX_VALUE);
case DOUBLE, SCALED_FLOAT, COUNTER_DOUBLE -> randomDouble();
case FLOAT -> randomFloat();
case HALF_FLOAT -> HalfFloatPoint.sortableShortToHalfFloat(HalfFloatPoint.halfFloatToSortableShort(randomFloat()));
diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/date_nanos.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/date_nanos.csv-spec
index daa45825b93f..0d113c042256 100644
--- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/date_nanos.csv-spec
+++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/date_nanos.csv-spec
@@ -216,11 +216,40 @@ millis:date | nanos:date_nanos | num:long
2023-10-23T13:33:34.937Z | 2023-10-23T13:33:34.937193000Z | 1698068014937193000
;
+date nanos greater than millis
+required_capability: date_nanos_type
+required_capability: date_nanos_compare_to_millis
+
+FROM date_nanos | WHERE MV_MIN(nanos) > TO_DATETIME("2023-10-23T12:27:28.948Z") | SORT nanos DESC;
+
+millis:date | nanos:date_nanos | num:long
+2023-10-23T13:55:01.543Z | 2023-10-23T13:55:01.543123456Z | 1698069301543123456
+2023-10-23T13:53:55.832Z | 2023-10-23T13:53:55.832987654Z | 1698069235832987654
+2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015787878Z | 1698069175015787878
+2023-10-23T13:51:54.732Z | 2023-10-23T13:51:54.732102837Z | 1698069114732102837
+2023-10-23T13:33:34.937Z | 2023-10-23T13:33:34.937193000Z | 1698068014937193000
+;
+
date nanos greater than or equal
required_capability: to_date_nanos
required_capability: date_nanos_binary_comparison
-FROM date_nanos | WHERE MV_MIN(nanos) >= TO_DATE_NANOS("2023-10-23T12:27:28.948000000Z") | SORT nanos DESC;
+FROM date_nanos | WHERE MV_MIN(nanos) >= TO_DATE_NANOS("2023-10-23T12:27:28.948Z") | SORT nanos DESC;
+
+millis:date | nanos:date_nanos | num:long
+2023-10-23T13:55:01.543Z | 2023-10-23T13:55:01.543123456Z | 1698069301543123456
+2023-10-23T13:53:55.832Z | 2023-10-23T13:53:55.832987654Z | 1698069235832987654
+2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015787878Z | 1698069175015787878
+2023-10-23T13:51:54.732Z | 2023-10-23T13:51:54.732102837Z | 1698069114732102837
+2023-10-23T13:33:34.937Z | 2023-10-23T13:33:34.937193000Z | 1698068014937193000
+2023-10-23T12:27:28.948Z | 2023-10-23T12:27:28.948000000Z | 1698064048948000000
+;
+
+date nanos greater than or equal millis
+required_capability: date_nanos_type
+required_capability: date_nanos_compare_to_millis
+
+FROM date_nanos | WHERE MV_MIN(nanos) >= TO_DATETIME("2023-10-23T12:27:28.948Z") | SORT nanos DESC;
millis:date | nanos:date_nanos | num:long
2023-10-23T13:55:01.543Z | 2023-10-23T13:55:01.543123456Z | 1698069301543123456
@@ -231,11 +260,23 @@ millis:date | nanos:date_nanos | num:long
2023-10-23T12:27:28.948Z | 2023-10-23T12:27:28.948000000Z | 1698064048948000000
;
+
date nanos less than
required_capability: to_date_nanos
required_capability: date_nanos_binary_comparison
-FROM date_nanos | WHERE MV_MIN(nanos) < TO_DATE_NANOS("2023-10-23T12:27:28.948000000Z") AND millis > "2000-01-01" | SORT nanos DESC;
+FROM date_nanos | WHERE MV_MIN(nanos) < TO_DATE_NANOS("2023-10-23T12:27:28.948Z") AND millis > "2000-01-01" | SORT nanos DESC;
+
+millis:date | nanos:date_nanos | num:long
+2023-10-23T12:15:03.360Z | 2023-10-23T12:15:03.360103847Z | 1698063303360103847
+2023-10-23T12:15:03.360Z | 2023-10-23T12:15:03.360103847Z | 1698063303360103847
+;
+
+date nanos less than millis
+required_capability: date_nanos_type
+required_capability: date_nanos_compare_to_millis
+
+FROM date_nanos | WHERE MV_MIN(nanos) < TO_DATETIME("2023-10-23T12:27:28.948Z") AND millis > "2000-01-01" | SORT nanos DESC;
millis:date | nanos:date_nanos | num:long
2023-10-23T12:15:03.360Z | 2023-10-23T12:15:03.360103847Z | 1698063303360103847
@@ -246,7 +287,19 @@ date nanos less than equal
required_capability: to_date_nanos
required_capability: date_nanos_binary_comparison
-FROM date_nanos | WHERE MV_MIN(nanos) <= TO_DATE_NANOS("2023-10-23T12:27:28.948000000Z") AND millis > "2000-01-01" | SORT nanos DESC;
+FROM date_nanos | WHERE MV_MIN(nanos) <= TO_DATE_NANOS("2023-10-23T12:27:28.948Z") AND millis > "2000-01-01" | SORT nanos DESC;
+
+millis:date | nanos:date_nanos | num:long
+2023-10-23T12:27:28.948Z | 2023-10-23T12:27:28.948000000Z | 1698064048948000000
+2023-10-23T12:15:03.360Z | 2023-10-23T12:15:03.360103847Z | 1698063303360103847
+2023-10-23T12:15:03.360Z | 2023-10-23T12:15:03.360103847Z | 1698063303360103847
+;
+
+date nanos less than equal millis
+required_capability: date_nanos_type
+required_capability: date_nanos_compare_to_millis
+
+FROM date_nanos | WHERE MV_MIN(nanos) <= TO_DATETIME("2023-10-23T12:27:28.948Z") AND millis > "2000-01-01" | SORT nanos DESC;
millis:date | nanos:date_nanos | num:long
2023-10-23T12:27:28.948Z | 2023-10-23T12:27:28.948000000Z | 1698064048948000000
@@ -254,6 +307,7 @@ millis:date | nanos:date_nanos | num:long
2023-10-23T12:15:03.360Z | 2023-10-23T12:15:03.360103847Z | 1698063303360103847
;
+
date nanos equals
required_capability: to_date_nanos
required_capability: date_nanos_binary_comparison
@@ -264,6 +318,25 @@ millis:date | nanos:date_nanos | num:long
2023-10-23T12:27:28.948Z | 2023-10-23T12:27:28.948000000Z | 1698064048948000000
;
+date nanos equals millis exact match
+required_capability: date_nanos_type
+required_capability: date_nanos_compare_to_millis
+
+FROM date_nanos | WHERE MV_MIN(nanos) == TO_DATETIME("2023-10-23T12:27:28.948Z");
+
+millis:date | nanos:date_nanos | num:long
+2023-10-23T12:27:28.948Z | 2023-10-23T12:27:28.948000000Z | 1698064048948000000
+;
+
+date nanos equals millis without exact match
+required_capability: date_nanos_type
+required_capability: date_nanos_compare_to_millis
+
+FROM date_nanos | WHERE MV_MIN(nanos) == TO_DATETIME("2023-10-23T13:33:34.937");
+
+millis:date | nanos:date_nanos | num:long
+;
+
date nanos not equals
required_capability: to_date_nanos
required_capability: date_nanos_binary_comparison
@@ -280,6 +353,22 @@ millis:date | nanos:date_nanos | num:long
2023-10-23T12:15:03.360Z | 2023-10-23T12:15:03.360103847Z | 1698063303360103847
;
+date nanos not equals millis
+required_capability: date_nanos_type
+required_capability: date_nanos_compare_to_millis
+
+FROM date_nanos | WHERE MV_MIN(nanos) != TO_DATETIME("2023-10-23T12:27:28.948Z") AND millis > "2000-01-01" | SORT nanos DESC;
+
+millis:date | nanos:date_nanos | num:long
+2023-10-23T13:55:01.543Z | 2023-10-23T13:55:01.543123456Z | 1698069301543123456
+2023-10-23T13:53:55.832Z | 2023-10-23T13:53:55.832987654Z | 1698069235832987654
+2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015787878Z | 1698069175015787878
+2023-10-23T13:51:54.732Z | 2023-10-23T13:51:54.732102837Z | 1698069114732102837
+2023-10-23T13:33:34.937Z | 2023-10-23T13:33:34.937193000Z | 1698068014937193000
+2023-10-23T12:15:03.360Z | 2023-10-23T12:15:03.360103847Z | 1698063303360103847
+2023-10-23T12:15:03.360Z | 2023-10-23T12:15:03.360103847Z | 1698063303360103847
+;
+
date nanos to long, index version
required_capability: to_date_nanos
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsMillisNanosEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsMillisNanosEvaluator.java
new file mode 100644
index 000000000000..b5013c408050
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsMillisNanosEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Equals}.
+ * This class is generated. Do not edit it.
+ */
+public final class EqualsMillisNanosEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public EqualsMillisNanosEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(Equals.processMillisNanos(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, Equals.processMillisNanos(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "EqualsMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public EqualsMillisNanosEvaluator get(DriverContext context) {
+ return new EqualsMillisNanosEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "EqualsMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsNanosMillisEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsNanosMillisEvaluator.java
new file mode 100644
index 000000000000..3ed1e922608e
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsNanosMillisEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Equals}.
+ * This class is generated. Do not edit it.
+ */
+public final class EqualsNanosMillisEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public EqualsNanosMillisEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(Equals.processNanosMillis(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, Equals.processNanosMillis(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "EqualsNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public EqualsNanosMillisEvaluator get(DriverContext context) {
+ return new EqualsNanosMillisEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "EqualsNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanMillisNanosEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanMillisNanosEvaluator.java
new file mode 100644
index 000000000000..bdd877c7f866
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanMillisNanosEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThan}.
+ * This class is generated. Do not edit it.
+ */
+public final class GreaterThanMillisNanosEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public GreaterThanMillisNanosEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(GreaterThan.processMillisNanos(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, GreaterThan.processMillisNanos(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "GreaterThanMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public GreaterThanMillisNanosEvaluator get(DriverContext context) {
+ return new GreaterThanMillisNanosEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "GreaterThanMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanNanosMillisEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanNanosMillisEvaluator.java
new file mode 100644
index 000000000000..d509547eb17c
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanNanosMillisEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThan}.
+ * This class is generated. Do not edit it.
+ */
+public final class GreaterThanNanosMillisEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public GreaterThanNanosMillisEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(GreaterThan.processNanosMillis(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, GreaterThan.processNanosMillis(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "GreaterThanNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public GreaterThanNanosMillisEvaluator get(DriverContext context) {
+ return new GreaterThanNanosMillisEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "GreaterThanNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualMillisNanosEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualMillisNanosEvaluator.java
new file mode 100644
index 000000000000..7a0da0a55d0d
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualMillisNanosEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThanOrEqual}.
+ * This class is generated. Do not edit it.
+ */
+public final class GreaterThanOrEqualMillisNanosEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public GreaterThanOrEqualMillisNanosEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(GreaterThanOrEqual.processMillisNanos(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, GreaterThanOrEqual.processMillisNanos(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "GreaterThanOrEqualMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public GreaterThanOrEqualMillisNanosEvaluator get(DriverContext context) {
+ return new GreaterThanOrEqualMillisNanosEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "GreaterThanOrEqualMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualNanosMillisEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualNanosMillisEvaluator.java
new file mode 100644
index 000000000000..d4386a64aaf8
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualNanosMillisEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThanOrEqual}.
+ * This class is generated. Do not edit it.
+ */
+public final class GreaterThanOrEqualNanosMillisEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public GreaterThanOrEqualNanosMillisEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(GreaterThanOrEqual.processNanosMillis(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, GreaterThanOrEqual.processNanosMillis(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "GreaterThanOrEqualNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public GreaterThanOrEqualNanosMillisEvaluator get(DriverContext context) {
+ return new GreaterThanOrEqualNanosMillisEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "GreaterThanOrEqualNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanMillisNanosEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanMillisNanosEvaluator.java
new file mode 100644
index 000000000000..21d7d50af5b1
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanMillisNanosEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThan}.
+ * This class is generated. Do not edit it.
+ */
+public final class LessThanMillisNanosEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public LessThanMillisNanosEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(LessThan.processMillisNanos(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, LessThan.processMillisNanos(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "LessThanMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public LessThanMillisNanosEvaluator get(DriverContext context) {
+ return new LessThanMillisNanosEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "LessThanMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanNanosMillisEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanNanosMillisEvaluator.java
new file mode 100644
index 000000000000..48593f9d537f
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanNanosMillisEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThan}.
+ * This class is generated. Do not edit it.
+ */
+public final class LessThanNanosMillisEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public LessThanNanosMillisEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(LessThan.processNanosMillis(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, LessThan.processNanosMillis(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "LessThanNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public LessThanNanosMillisEvaluator get(DriverContext context) {
+ return new LessThanNanosMillisEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "LessThanNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualMillisNanosEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualMillisNanosEvaluator.java
new file mode 100644
index 000000000000..06973e71e834
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualMillisNanosEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThanOrEqual}.
+ * This class is generated. Do not edit it.
+ */
+public final class LessThanOrEqualMillisNanosEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public LessThanOrEqualMillisNanosEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(LessThanOrEqual.processMillisNanos(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, LessThanOrEqual.processMillisNanos(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "LessThanOrEqualMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public LessThanOrEqualMillisNanosEvaluator get(DriverContext context) {
+ return new LessThanOrEqualMillisNanosEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "LessThanOrEqualMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualNanosMillisEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualNanosMillisEvaluator.java
new file mode 100644
index 000000000000..4763629873d0
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualNanosMillisEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThanOrEqual}.
+ * This class is generated. Do not edit it.
+ */
+public final class LessThanOrEqualNanosMillisEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public LessThanOrEqualNanosMillisEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(LessThanOrEqual.processNanosMillis(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, LessThanOrEqual.processNanosMillis(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "LessThanOrEqualNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public LessThanOrEqualNanosMillisEvaluator get(DriverContext context) {
+ return new LessThanOrEqualNanosMillisEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "LessThanOrEqualNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsMillisNanosEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsMillisNanosEvaluator.java
new file mode 100644
index 000000000000..9bede03737a5
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsMillisNanosEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link NotEquals}.
+ * This class is generated. Do not edit it.
+ */
+public final class NotEqualsMillisNanosEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public NotEqualsMillisNanosEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(NotEquals.processMillisNanos(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, NotEquals.processMillisNanos(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "NotEqualsMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public NotEqualsMillisNanosEvaluator get(DriverContext context) {
+ return new NotEqualsMillisNanosEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "NotEqualsMillisNanosEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsNanosMillisEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsNanosMillisEvaluator.java
new file mode 100644
index 000000000000..e8e28eec7ee2
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsNanosMillisEvaluator.java
@@ -0,0 +1,148 @@
+// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+// or more contributor license agreements. Licensed under the Elastic License
+// 2.0; you may not use this file except in compliance with the Elastic License
+// 2.0.
+package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
+
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.String;
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BooleanBlock;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.LongVector;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.Warnings;
+import org.elasticsearch.core.Releasables;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+/**
+ * {@link EvalOperator.ExpressionEvaluator} implementation for {@link NotEquals}.
+ * This class is generated. Do not edit it.
+ */
+public final class NotEqualsNanosMillisEvaluator implements EvalOperator.ExpressionEvaluator {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator lhs;
+
+ private final EvalOperator.ExpressionEvaluator rhs;
+
+ private final DriverContext driverContext;
+
+ private Warnings warnings;
+
+ public NotEqualsNanosMillisEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs,
+ EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.driverContext = driverContext;
+ }
+
+ @Override
+ public Block eval(Page page) {
+ try (LongBlock lhsBlock = (LongBlock) lhs.eval(page)) {
+ try (LongBlock rhsBlock = (LongBlock) rhs.eval(page)) {
+ LongVector lhsVector = lhsBlock.asVector();
+ if (lhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ LongVector rhsVector = rhsBlock.asVector();
+ if (rhsVector == null) {
+ return eval(page.getPositionCount(), lhsBlock, rhsBlock);
+ }
+ return eval(page.getPositionCount(), lhsVector, rhsVector).asBlock();
+ }
+ }
+ }
+
+ public BooleanBlock eval(int positionCount, LongBlock lhsBlock, LongBlock rhsBlock) {
+ try(BooleanBlock.Builder result = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ if (lhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (lhsBlock.getValueCount(p) != 1) {
+ if (lhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.isNull(p)) {
+ result.appendNull();
+ continue position;
+ }
+ if (rhsBlock.getValueCount(p) != 1) {
+ if (rhsBlock.getValueCount(p) > 1) {
+ warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
+ }
+ result.appendNull();
+ continue position;
+ }
+ result.appendBoolean(NotEquals.processNanosMillis(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p))));
+ }
+ return result.build();
+ }
+ }
+
+ public BooleanVector eval(int positionCount, LongVector lhsVector, LongVector rhsVector) {
+ try(BooleanVector.FixedBuilder result = driverContext.blockFactory().newBooleanVectorFixedBuilder(positionCount)) {
+ position: for (int p = 0; p < positionCount; p++) {
+ result.appendBoolean(p, NotEquals.processNanosMillis(lhsVector.getLong(p), rhsVector.getLong(p)));
+ }
+ return result.build();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "NotEqualsNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(lhs, rhs);
+ }
+
+ private Warnings warnings() {
+ if (warnings == null) {
+ this.warnings = Warnings.createWarnings(
+ driverContext.warningsMode(),
+ source.source().getLineNumber(),
+ source.source().getColumnNumber(),
+ source.text()
+ );
+ }
+ return warnings;
+ }
+
+ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
+ private final Source source;
+
+ private final EvalOperator.ExpressionEvaluator.Factory lhs;
+
+ private final EvalOperator.ExpressionEvaluator.Factory rhs;
+
+ public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory lhs,
+ EvalOperator.ExpressionEvaluator.Factory rhs) {
+ this.source = source;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ @Override
+ public NotEqualsNanosMillisEvaluator get(DriverContext context) {
+ return new NotEqualsNanosMillisEvaluator(source, lhs.get(context), rhs.get(context), context);
+ }
+
+ @Override
+ public String toString() {
+ return "NotEqualsNanosMillisEvaluator[" + "lhs=" + lhs + ", rhs=" + rhs + "]";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
index c8b2b2008ce0..3bc62e629391 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
@@ -345,6 +345,11 @@ public enum Cap {
*/
DATE_NANOS_BINARY_COMPARISON(),
+ /**
+ * Support for mixed comparisons between nanosecond and millisecond dates
+ */
+ DATE_NANOS_COMPARE_TO_MILLIS(),
+
/**
* Support Least and Greatest functions on Date Nanos type
*/
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java
index d6f0ff766eb4..ecfe1aa7f916 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java
@@ -41,6 +41,7 @@
import org.elasticsearch.xpack.esql.expression.function.grouping.GroupingFunction;
import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.Neg;
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.Equals;
+import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison;
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.NotEquals;
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
import org.elasticsearch.xpack.esql.plan.logical.Enrich;
@@ -596,7 +597,11 @@ private void gatherMetrics(LogicalPlan plan, BitSet b) {
}
/**
- * Limit QL's comparisons to types we support.
+ * Limit QL's comparisons to types we support. This should agree with
+ * {@link EsqlBinaryComparison}'s checkCompatibility method
+ *
+ * @return null if the given binary comparison has valid input types,
+ * otherwise a failure message suitable to return to the user.
*/
public static Failure validateBinaryComparison(BinaryComparison bc) {
if (bc.left().dataType().isNumeric()) {
@@ -641,6 +646,12 @@ public static Failure validateBinaryComparison(BinaryComparison bc) {
if (DataType.isString(bc.left().dataType()) && DataType.isString(bc.right().dataType())) {
return null;
}
+
+ // Allow mixed millisecond and nanosecond binary comparisons
+ if (bc.left().dataType().isDate() && bc.right().dataType().isDate()) {
+ return null;
+ }
+
if (bc.left().dataType() != bc.right().dataType()) {
return fail(
bc,
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java
index 6bb249385aff..464553977d3c 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java
@@ -8,6 +8,7 @@
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.time.DateUtils;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.predicate.Negatable;
@@ -95,11 +96,28 @@ public Equals(
description = "An expression."
) Expression right
) {
- super(source, left, right, BinaryComparisonOperation.EQ, evaluatorMap);
+ super(
+ source,
+ left,
+ right,
+ BinaryComparisonOperation.EQ,
+ evaluatorMap,
+ EqualsNanosMillisEvaluator.Factory::new,
+ EqualsMillisNanosEvaluator.Factory::new
+ );
}
public Equals(Source source, Expression left, Expression right, ZoneId zoneId) {
- super(source, left, right, BinaryComparisonOperation.EQ, zoneId, evaluatorMap);
+ super(
+ source,
+ left,
+ right,
+ BinaryComparisonOperation.EQ,
+ zoneId,
+ evaluatorMap,
+ EqualsNanosMillisEvaluator.Factory::new,
+ EqualsMillisNanosEvaluator.Factory::new
+ );
}
@Override
@@ -142,6 +160,16 @@ static boolean processLongs(long lhs, long rhs) {
return lhs == rhs;
}
+ @Evaluator(extraName = "MillisNanos")
+ static boolean processMillisNanos(long lhs, long rhs) {
+ return DateUtils.compareNanosToMillis(rhs, lhs) == 0;
+ }
+
+ @Evaluator(extraName = "NanosMillis")
+ static boolean processNanosMillis(long lhs, long rhs) {
+ return DateUtils.compareNanosToMillis(lhs, rhs) == 0;
+ }
+
@Evaluator(extraName = "Doubles")
static boolean processDoubles(double lhs, double rhs) {
return lhs == rhs;
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EsqlBinaryComparison.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EsqlBinaryComparison.java
index cbbf87fb6c4c..217c6528c9fd 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EsqlBinaryComparison.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EsqlBinaryComparison.java
@@ -35,6 +35,8 @@ public abstract class EsqlBinaryComparison extends BinaryComparison implements E
private final Map