Skip to content

Conversation

@felixbarny
Copy link
Member

Only parses the parameters, doesn't actually do anything with them, yet.

I'm hoping we can make start/end optional and a consequence of not specifying is that the start() and end() functions return an error.

This seems like a sensible pattern when used within Kibana, for example when creating an ES|QL-based visualization. Kibana is already supplying a filter for the time range outside of the query itself, so having to specify start/end would be redundant. The start/end parameters can still be used within and outside of Kibana but will likely mostly be useful outside of Kibana, and act similar to TRANGE.

We'll need to solve the issue of increasing the time window we load data from. But I see this as a separate issue that we should solve when tackling window functions. This includes handling the complexity of mixing start/end, time filtering using filter (as Kibana does), and TBUCKET/WHERE filtering in the same query.

Examples:

# instant query
PROMQL time `2025-10-31T00:00:00Z` (avg(foo))
# range query with explicit start and end
PROMQL start `2025-10-31T00:00:00Z` end `2025-10-31T01:00:00Z` step 1m (avg(foo))
# range query with implicit time bounds
# doesn't support calling start() or end() functions
PROMQL step 5m (avg(foo))

The responses in PromQL look different for these (`value` vs `values`)
@felixbarny felixbarny requested a review from costin October 31, 2025 17:07
@felixbarny felixbarny self-assigned this Oct 31, 2025
@felixbarny felixbarny added the :StorageEngine/ES|QL Timeseries / metrics / logsdb capabilities in ES|QL label Oct 31, 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 Oct 31, 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.

Left a round of comments

Copy link
Member

Choose a reason for hiding this comment

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

This should now fixed - please verify if that's the case on your end as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Some tests in PromqlLogicalPlanOptimizerTests are still failing (before and after this change). Maybe you meant PromqlVerifierTests? Some are working now but not all.

}

public void testValidInstantQuery() {
PromqlCommand promql = parse("TS test | PROMQL time `2025-10-31T00:00:00Z` (avg(foo))");
Copy link
Member

Choose a reason for hiding this comment

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

foo is a quoted identifier that is a reference to a field which the parser should translate into an UnresolvedAttribute(foo).
If you want to parse it as a value use define it as a string - "2025..."

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'll follow up on that shortly. I'd like to do that in a separate change as it needs changes to the grammar.

@felixbarny felixbarny merged commit 8272dcd into elastic:esql/promql Nov 3, 2025
8 of 34 checks passed
@felixbarny felixbarny deleted the promql-parameter-parsing branch November 3, 2025 08:43
phananh1010 added a commit to phananh1010/elasticsearch that referenced this pull request Nov 6, 2025
BASE=2351e395658a305869ca62d07951a0ff036f8d79
HEAD=24e35edae64567854d1b1e47ca3abd1a1691a571
Branch=esql/promql
phananh1010 added a commit to phananh1010/elasticsearch that referenced this pull request Nov 7, 2025
BASE=2351e395658a305869ca62d07951a0ff036f8d79
HEAD=24e35edae64567854d1b1e47ca3abd1a1691a571
Branch=esql/promql
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