Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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])));

Expand Down
Original file line number Diff line number Diff line change
@@ -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
;

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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])));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))""");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: { } }
Expand Down