Skip to content

Conversation

@felixbarny
Copy link
Member

@felixbarny felixbarny commented Nov 13, 2025

The start/end parameters are optional. If set, this creates a simple filter on the timestamp.

If start/end is not set, this doesn't create a filter and if @ start() and @ end() functions are used, it throws an error during parsing.

We don't attempt to infer start/end from other filters and we don't do anything special if there's another filter on @timestamp.

For instant queries where start=end=time, this essentially creates a filter that only includes data for a particular instant. We'll need to wire the lookback that will come after the initial window function support later on. Right now, instant queries will essentially always return an empty result. Maybe we just add a verifier rule to disallow instant queries.

@felixbarny felixbarny requested a review from costin November 13, 2025 15:21
@felixbarny felixbarny self-assigned this Nov 13, 2025
@felixbarny felixbarny added the :StorageEngine/ES|QL Timeseries / metrics / logsdb capabilities in ES|QL label Nov 13, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@elasticsearchmachine elasticsearchmachine added the external-contributor Pull request authored by a developer outside the Elasticsearch team label Nov 13, 2025
Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest an improvement in creating the filter otherwise LGTM

return promqlPlan;
}

private static LogicalPlan withTimestampFilter(PromqlCommand promqlCommand, LogicalPlan plan) {
Copy link
Member

@costin costin Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since only one of start and end might be missing, handle each individually then assemble the filter using Predicates.combineAnd at the end:

List<Expression> timestampFilter = new ArrayList<>();

if (promqlCommand.start() ..) {
      timestampFilter.add(new GreaterThan,...)
}
if (promqlCommand.end() ..) {
      timestampFilter.add(new LessThan...)
}

if (timestampFilter.isEmpty() == false) {
        plan = new Filter(..., plan, Predicates.combineAnd(timestampFilter)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since only one of start and end might be missing

I don't think that can happen. We're validating that either both or none are set:

if (start == null || end == null) {
throw new ParsingException(
source,
"Parameters [{}] and [{}] must either both be specified or both be omitted for a range query",
START,
END
);
}

@costin costin deleted the branch elastic:esql/promql November 20, 2025 18:16
@costin costin closed this Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team :StorageEngine/ES|QL Timeseries / metrics / logsdb capabilities in ES|QL Team:StorageEngine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants