Skip to content
Closed
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 @@ -117,10 +117,10 @@ public LogicalPlanOptimizer(LogicalOptimizerContext optimizerContext) {
public LogicalPlan optimize(LogicalPlan verified) {
var optimized = execute(verified);

// Failures failures = verifier.verify(optimized, verified.output());
// if (failures.hasFailures()) {
// throw new VerificationException(failures);
// }
// Failures failures = verifier.verify(optimized, verified.output());
// if (failures.hasFailures()) {
// throw new VerificationException(failures);
// }
optimized.setOptimized();
return optimized;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,24 @@ public LogicalPlan visitSelector(PromqlBaseParser.SelectorContext ctx) {
throw new ParsingException(source(labelsCtx), "Vector selector must contain at least one non-empty matcher");
}
}
final LabelMatchers matchers = new LabelMatchers(labels);
UnresolvedAttribute timestamp = new UnresolvedAttribute(source, MetadataAttribute.TIMESTAMP_FIELD);

Evaluation evaluation = visitEvaluation(ctx.evaluation());
TimeValue range = visitDuration(ctx.duration());
// TODO: TimeValue might not be needed after all
Expression rangeEx = new Literal(source(ctx.duration()), Duration.ofSeconds(range.getSeconds()), DataType.TIME_DURATION);
// fall back to default
if (evaluation == null) {
evaluation = new Evaluation(start);
}

final LabelMatchers matchers = new LabelMatchers(labels);
final Evaluation finalEvaluation = evaluation;
PromqlBaseParser.DurationContext duration = ctx.duration();
if (duration == null) {
return new InstantSelector(source, series, labelExpressions, matchers, finalEvaluation, timestamp);
}
TimeValue range = visitDuration(duration);
// TODO: TimeValue might not be needed after all
Expression rangeEx = new Literal(source(duration), Duration.ofSeconds(range.getSeconds()), DataType.TIME_DURATION);

UnresolvedAttribute timestamp = new UnresolvedAttribute(source, MetadataAttribute.TIMESTAMP_FIELD);

return range == null
? new InstantSelector(source, series, labelExpressions, matchers, finalEvaluation, timestamp)
: new RangeSelector(source, series, labelExpressions, matchers, rangeEx, finalEvaluation, timestamp);
return new RangeSelector(source, series, labelExpressions, matchers, rangeEx, finalEvaluation, timestamp);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public int hashCode() {
public boolean equals(Object obj) {
if (super.equals(obj)) {

PromqlCommand other = (PromqlCommand) obj;
return Objects.equals(child(), other.child()) && Objects.equals(promqlPlan, other.promqlPlan);
}
PromqlCommand other = (PromqlCommand) obj;
return Objects.equals(child(), other.child()) && Objects.equals(promqlPlan, other.promqlPlan);
}

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.elasticsearch.TransportVersion;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.xpack.esql.EsqlTestUtils;
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
import org.elasticsearch.xpack.esql.analysis.Analyzer;
Expand All @@ -23,7 +22,6 @@
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
import org.junit.BeforeClass;

import java.util.Collections;
import java.util.Map;

import static java.util.Collections.emptyMap;
Expand Down