Skip to content

Conversation

@felixbarny
Copy link
Member

This is a variant of #138027 where the target is main instead of the now merged esql/promql branch.

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 self-assigned this Nov 21, 2025
@felixbarny felixbarny added >non-issue :StorageEngine/ES|QL Timeseries / metrics / logsdb capabilities in ES|QL labels Nov 21, 2025
@elasticsearchmachine elasticsearchmachine added Team:StorageEngine v9.3.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Nov 21, 2025
@elasticsearchmachine
Copy link
Collaborator

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

query = query.replace("$now", '"' + Instant.now().toString() + '"');
var analyzed = tsAnalyzer.analyze(parser.createStatement(query));
logger.trace(analyzed);
logger.trace("analyzed plan:\n{}", analyzed);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove? Or set to debug? Same below.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the trace level is fine to be able to debug/inspect the plan during testing. I've removed the redundant logger.trace(plan) in all of the other tests as we're doing that in here already.

List<LogicalPlan> collect = plan.collect(Bucket.class::isInstance);
logger.trace(plan);
var filters = plan.collect(Filter.class::isInstance);
assertThat(filters, hasSize(1));
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we have 2?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's one filter with multiple conditions (metric not null, timestamp >= start, timestamp <= end)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've adjusted the assertion in 6f88cf7 to check that there are two conditions for @timestamp.

@felixbarny felixbarny merged commit 318c807 into elastic:main Nov 21, 2025
34 checks passed
@felixbarny felixbarny deleted the promql-wire-start-end-2 branch November 21, 2025 14:12
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 >non-issue :StorageEngine/ES|QL Timeseries / metrics / logsdb capabilities in ES|QL Team:StorageEngine v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants