Skip to content

Commit 0c05606

Browse files
committed
Rename stop parameter to end
This is to align more closely with the query parameter names for the prometheus range_query API.
1 parent c602a60 commit 0c05606

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,8 @@ public PlanFactory visitSampleCommand(EsqlBaseParser.SampleCommandContext ctx) {
11461146
public PlanFactory visitPromqlCommand(EsqlBaseParser.PromqlCommandContext ctx) {
11471147
Source source = source(ctx);
11481148
Map<String, Expression> params = new HashMap<>();
1149-
String TIME = "time", START = "start", STOP = "stop", STEP = "step";
1150-
Set<String> allowed = Set.of(TIME, START, STOP, STEP);
1149+
String TIME = "time", START = "start", END = "end", STEP = "step";
1150+
Set<String> allowed = Set.of(TIME, START, END, STEP);
11511151

11521152
if (ctx.promqlParam().isEmpty()) {
11531153
throw new ParsingException(source(ctx), "Parameter [{}] or [{}] is required", STEP, TIME);
@@ -1175,21 +1175,21 @@ public PlanFactory visitPromqlCommand(EsqlBaseParser.PromqlCommandContext ctx) {
11751175
// Validation logic for time parameters
11761176
Expression time = params.get(TIME);
11771177
Expression start = params.get(START);
1178-
Expression stop = params.get(STOP);
1178+
Expression end = params.get(END);
11791179
Expression step = params.get(STEP);
11801180

1181-
if (time != null && (start != null || stop != null || step != null)) {
1181+
if (time != null && (start != null || end != null || step != null)) {
11821182
throw new ParsingException(
11831183
source,
11841184
"Specify either [{}] for instant query or [{}}], [{}] or [{}}] for a range query",
11851185
TIME,
11861186
STEP,
11871187
START,
1188-
STOP
1188+
END
11891189
);
11901190
}
1191-
if ((start != null || stop != null) && step == null) {
1192-
throw new ParsingException(source, "[{}}] is required alongside [{}}] or [{}}]", STEP, START, STOP);
1191+
if ((start != null || end != null) && step == null) {
1192+
throw new ParsingException(source, "[{}}] is required alongside [{}}] or [{}}]", STEP, START, END);
11931193
}
11941194

11951195
// TODO: Perform type and value validation
@@ -1220,7 +1220,7 @@ public PlanFactory visitPromqlCommand(EsqlBaseParser.PromqlCommandContext ctx) {
12201220

12211221
return plan -> time != null
12221222
? new PromqlCommand(source, plan, promqlPlan, time)
1223-
: new PromqlCommand(source, plan, promqlPlan, start, stop, step);
1223+
: new PromqlCommand(source, plan, promqlPlan, start, end, step);
12241224
}
12251225

12261226
private static ParsingException getParsingException(ParsingException pe, int promqlStartLine, int promqlStartColumn) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/promql/PromqlCommand.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package org.elasticsearch.xpack.esql.plan.logical.promql;
99

1010
import org.elasticsearch.common.io.stream.StreamOutput;
11-
import org.elasticsearch.core.TimeValue;
1211
import org.elasticsearch.xpack.esql.capabilities.TelemetryAware;
1312
import org.elasticsearch.xpack.esql.core.expression.Expression;
1413
import org.elasticsearch.xpack.esql.core.expression.Literal;
@@ -28,34 +27,34 @@
2827
public class PromqlCommand extends UnaryPlan implements TelemetryAware {
2928

3029
private final LogicalPlan promqlPlan;
31-
private final Expression start, stop, step;
30+
private final Expression start, end, step;
3231

3332
// Instant query constructor - shortcut for a range constructor
3433
public PromqlCommand(Source source, LogicalPlan child, LogicalPlan promqlPlan, Expression time) {
3534
this(source, child, promqlPlan, time, time, Literal.timeDuration(source, Duration.ZERO));
3635
}
3736

3837
// Range query constructor
39-
public PromqlCommand(Source source, LogicalPlan child, LogicalPlan promqlPlan, Expression start, Expression stop, Expression step) {
38+
public PromqlCommand(Source source, LogicalPlan child, LogicalPlan promqlPlan, Expression start, Expression end, Expression step) {
4039
super(source, child);
4140
this.promqlPlan = promqlPlan;
4241
this.start = start;
43-
this.stop = stop;
42+
this.end = end;
4443
this.step = step;
4544
}
4645

4746
@Override
4847
protected NodeInfo<PromqlCommand> info() {
49-
return NodeInfo.create(this, PromqlCommand::new, child(), promqlPlan(), start(), stop(), step());
48+
return NodeInfo.create(this, PromqlCommand::new, child(), promqlPlan(), start(), end(), step());
5049
}
5150

5251
@Override
5352
public PromqlCommand replaceChild(LogicalPlan newChild) {
54-
return new PromqlCommand(source(), newChild, promqlPlan(), start(), stop(), step());
53+
return new PromqlCommand(source(), newChild, promqlPlan(), start(), end(), step());
5554
}
5655

5756
public PromqlCommand withPromqlPlan(LogicalPlan newPromqlPlan) {
58-
return new PromqlCommand(source(), child(), newPromqlPlan, start(), stop(), step());
57+
return new PromqlCommand(source(), child(), newPromqlPlan, start(), end(), step());
5958
}
6059

6160
@Override
@@ -86,8 +85,8 @@ public Expression start() {
8685
return start;
8786
}
8887

89-
public Expression stop() {
90-
return stop;
88+
public Expression end() {
89+
return end;
9190
}
9291

9392
public Expression step() {
@@ -96,7 +95,7 @@ public Expression step() {
9695

9796
@Override
9897
public int hashCode() {
99-
return Objects.hash(child(), start, stop, step, promqlPlan);
98+
return Objects.hash(child(), start, end, step, promqlPlan);
10099
}
101100

102101
@Override
@@ -114,10 +113,10 @@ public boolean equals(Object obj) {
114113
public String nodeString() {
115114
StringBuilder sb = new StringBuilder();
116115
sb.append(nodeName());
117-
if (start == stop) {
116+
if (start == end) {
118117
sb.append("time=").append(start);
119118
} else {
120-
sb.append("start=").append(start).append(", stop=").append(stop).append(", step=").append(step);
119+
sb.append("start=").append(start).append(", end=").append(end).append(", step=").append(step);
121120
}
122121
sb.append(" promql=[<>\n");
123122
sb.append(promqlPlan.toString());

0 commit comments

Comments
 (0)