diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Literal.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Literal.java index 9c347fcd96d0c..c07c1842c854a 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Literal.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Literal.java @@ -219,7 +219,7 @@ public static Literal timeDuration(Source source, Duration literal) { } public static Literal dateTime(Source source, Instant literal) { - return new Literal(source, literal, DataType.DATETIME); + return new Literal(source, literal.toEpochMilli(), DataType.DATETIME); } public static Literal integer(Source source, Integer literal) { diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeForkRestTest.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeForkRestTest.java index f355b9b2f92a3..0b2c7a05f0505 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeForkRestTest.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeForkRestTest.java @@ -62,7 +62,7 @@ protected void shouldSkipTest(String testName) throws IOException { assumeFalse( "Tests using PROMQL are not supported for now", - testCase.requiredCapabilities.contains(PROMQL_PRE_TECH_PREVIEW_V1.capabilityName()) + testCase.requiredCapabilities.contains(PROMQL_PRE_TECH_PREVIEW_V2.capabilityName()) ); assumeFalse( diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries-avg-over-time.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries-avg-over-time.csv-spec index 5e92836cf8a2c..2511c40cf8774 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries-avg-over-time.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries-avg-over-time.csv-spec @@ -18,7 +18,7 @@ cost:double | time_bucket:datetime ; avg_over_time_of_double_no_grouping_promql -required_capability: promql_pre_tech_preview_v1 +required_capability: promql_pre_tech_preview_v2 TS k8s | PROMQL step 1m (sum(avg_over_time(network.cost[1m]))) | SORT `sum(avg_over_time(network.cost[1m]))` DESC, step DESC | LIMIT 10; @@ -47,7 +47,7 @@ cost:double | time_bucket:datetime ; avg_over_time_of_double_no_grouping_single_bucket_promql -required_capability: promql_pre_tech_preview_v1 +required_capability: promql_pre_tech_preview_v2 TS k8s | PROMQL step 1h (sum(avg_over_time(network.cost[1h]))); diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries-promql.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries-promql.csv-spec new file mode 100644 index 0000000000000..c1bfdf0e8a36d --- /dev/null +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries-promql.csv-spec @@ -0,0 +1,11 @@ +promql_start_end_step +required_capability: promql_pre_tech_preview_v2 +TS k8s +| PROMQL step 5m start "2024-05-10T00:20:00.000Z" end "2024-05-10T00:25:00.000Z" ( + sum(avg_over_time(network.cost[5m])) + ); + +sum(avg_over_time(network.cost[5m])):double | step:date +50.25 | 2024-05-10T00:20:00.000Z +; + diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries.csv-spec index 09c7d46275589..8bc6538447fc8 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries.csv-spec @@ -133,7 +133,7 @@ max(rate(network.total_bytes_in)): double | time_bucket:date ; oneRateWithPromql -required_capability: promql_pre_tech_preview_v1 +required_capability: promql_pre_tech_preview_v2 TS k8s | PROMQL step 5m (max(rate(network.total_bytes_in[5m]))) | SORT step DESC | LIMIT 2; @@ -154,7 +154,7 @@ max(rate(network.total_bytes_in)): double | time_bucket:date ; oneRateWithSingleStepPromql -required_capability: promql_pre_tech_preview_v1 +required_capability: promql_pre_tech_preview_v2 TS k8s | PROMQL step 1h (max(rate(network.total_bytes_in[1h]))); 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 c4a33b2981a94..d11fbadc94529 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 @@ -1705,7 +1705,7 @@ public enum Cap { * As soon as we move into tech preview, we'll replace this capability with a "EXPONENTIAL_HISTOGRAM_TECH_PREVIEW" one. * At this point, we need to add new capabilities for any further changes. */ - PROMQL_PRE_TECH_PREVIEW_V1(Build.current().isSnapshot()), + PROMQL_PRE_TECH_PREVIEW_V2(Build.current().isSnapshot()), /** * KNN function adds support for k and visit_percentage options diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/PromqlFeatures.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/PromqlFeatures.java index 13f8facb49104..47fc53553fcd8 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/PromqlFeatures.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/PromqlFeatures.java @@ -21,6 +21,6 @@ private PromqlFeatures() { * Exists to provide a single point of change and minimize noise when upgrading capability versions. */ public static boolean isEnabled() { - return EsqlCapabilities.Cap.TS_COMMAND_V0.isEnabled() && EsqlCapabilities.Cap.PROMQL_PRE_TECH_PREVIEW_V1.isEnabled(); + return EsqlCapabilities.Cap.TS_COMMAND_V0.isEnabled() && EsqlCapabilities.Cap.PROMQL_PRE_TECH_PREVIEW_V2.isEnabled(); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java index 28054ab3ba236..f4e6b15c8da5b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java @@ -301,7 +301,7 @@ public final void test() throws Throwable { ); assumeFalse( "can't load metrics in csv tests", - testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.PROMQL_PRE_TECH_PREVIEW_V1.capabilityName()) + testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.PROMQL_PRE_TECH_PREVIEW_V2.capabilityName()) ); assumeFalse( "can't use QSTR function in csv tests", @@ -365,7 +365,7 @@ public final void test() throws Throwable { ); assumeFalse( "can't use PromQL in csv tests", - testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.PROMQL_PRE_TECH_PREVIEW_V1.capabilityName()) + testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.PROMQL_PRE_TECH_PREVIEW_V2.capabilityName()) ); if (Build.current().isSnapshot()) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/promql/PromqlParamsTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/promql/PromqlParamsTests.java index 9cc8c20c73059..e02a5e4f821a8 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/promql/PromqlParamsTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/promql/PromqlParamsTests.java @@ -39,8 +39,8 @@ public static void checkPromqlEnabled() { public void testValidRangeQuery() { PromqlCommand promql = parse("TS test | PROMQL start \"2025-10-31T00:00:00Z\" end \"2025-10-31T01:00:00Z\" step 1m (avg(foo))"); - assertThat(promql.start().value(), equalTo(Instant.parse("2025-10-31T00:00:00Z"))); - assertThat(promql.end().value(), equalTo(Instant.parse("2025-10-31T01:00:00Z"))); + assertThat(promql.start().value(), equalTo(Instant.parse("2025-10-31T00:00:00Z").toEpochMilli())); + assertThat(promql.end().value(), equalTo(Instant.parse("2025-10-31T01:00:00Z").toEpochMilli())); assertThat(promql.step().value(), equalTo(Duration.ofMinutes(1))); assertThat(promql.isRangeQuery(), equalTo(true)); assertThat(promql.isInstantQuery(), equalTo(false)); @@ -60,8 +60,8 @@ public void testValidRangeQueryParams() { ), PromqlCommand.class ); - assertThat(promql.start().value(), equalTo(Instant.parse("2025-10-31T00:00:00Z"))); - assertThat(promql.end().value(), equalTo(Instant.parse("2025-10-31T01:00:00Z"))); + assertThat(promql.start().value(), equalTo(Instant.parse("2025-10-31T00:00:00Z").toEpochMilli())); + assertThat(promql.end().value(), equalTo(Instant.parse("2025-10-31T01:00:00Z").toEpochMilli())); assertThat(promql.step().value(), equalTo(Duration.ofMinutes(1))); assertThat(promql.isRangeQuery(), equalTo(true)); assertThat(promql.isInstantQuery(), equalTo(false)); @@ -78,8 +78,8 @@ public void testValidRangeQueryOnlyStep() { public void testValidInstantQuery() { PromqlCommand promql = parse("TS test | PROMQL time \"2025-10-31T00:00:00Z\" (avg(foo))"); - assertThat(promql.start().value(), equalTo(Instant.parse("2025-10-31T00:00:00Z"))); - assertThat(promql.end().value(), equalTo(Instant.parse("2025-10-31T00:00:00Z"))); + assertThat(promql.start().value(), equalTo(Instant.parse("2025-10-31T00:00:00Z").toEpochMilli())); + assertThat(promql.end().value(), equalTo(Instant.parse("2025-10-31T00:00:00Z").toEpochMilli())); assertThat(promql.step().value(), nullValue()); assertThat(promql.isInstantQuery(), equalTo(true)); assertThat(promql.isRangeQuery(), equalTo(false)); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/telemetry/VerifierMetricsTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/telemetry/VerifierMetricsTests.java index 263f78e6a9156..0da890cd9edc0 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/telemetry/VerifierMetricsTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/telemetry/VerifierMetricsTests.java @@ -816,7 +816,7 @@ public void testBinaryPlanAfterSubqueryInFromCommand() { @AwaitsFix(bugUrl = "unresolved @timestamp field") public void testPromql() { - assumeTrue("PromQL required", EsqlCapabilities.Cap.PROMQL_PRE_TECH_PREVIEW_V1.isEnabled()); + assumeTrue("PromQL required", EsqlCapabilities.Cap.PROMQL_PRE_TECH_PREVIEW_V2.isEnabled()); Counters c = esql(""" TS metrics | PROMQL step 5m (sum(salary))"""); diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml index 3ed20a8842dfe..86d73348117df 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml @@ -58,7 +58,7 @@ setup: - ts_command_v0 - cosine_vector_similarity_function - inline_stats - - promql_pre_tech_preview_v1 + - promql_pre_tech_preview_v2 reason: "Test that should only be executed on snapshot versions" - do: { xpack.usage: { } }