Skip to content

Fix ESQL TS requests with LIMIT 0#144031

Merged
leontyevdv merged 13 commits intoelastic:mainfrom
leontyevdv:fix/fix-ts-command-with-limit-0-requests
Mar 12, 2026
Merged

Fix ESQL TS requests with LIMIT 0#144031
leontyevdv merged 13 commits intoelastic:mainfrom
leontyevdv:fix/fix-ts-command-with-limit-0-requests

Conversation

@leontyevdv
Copy link
Copy Markdown
Contributor

@leontyevdv leontyevdv commented Mar 11, 2026

When executing a query using the TS command with STATS dimension_field, a _timeseries column is added in runtime and is taken into account when validating the output.

It turns out that "LIMIT 0" is a corner case in which we replace the entire plan with a LocalRelation node so that there is no TimeSeriesAggregate and a verification step fails.

Query:

TS kibana_sample_data_logstsdb | STATS bytes_counter BY meow = BUCKET(@timestamp, 50, ?_tstart, ?_tend) | limit 0

Output:

Output has changed from [[bytes_counter{r}#30886, meow{r}#30884]] to [[bytes_counter{r}#30886, _timeseries{r}#30894, meow{r}#30884]]

Closes #144024

When executing a query using the TS command with STATS dimension_field,
a _timeseries column is added in runtime and is taken into account when
validating the output.

It turns out that "LIMIT 0" is a corner case in which we replace
the entire plan with a different one (LocalRelation) so that
there is no TimeSeriesAggregate and a verification step fails.

Closes elastic#144024
@leontyevdv leontyevdv requested a review from a team March 11, 2026 14:43
@leontyevdv leontyevdv self-assigned this Mar 11, 2026
@leontyevdv leontyevdv added >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :StorageEngine/TSDB You know, for Metrics :Analytics/ES|QL AKA ESQL Team:StorageEngine :StorageEngine/ES|QL Timeseries / metrics / PromQL / logsdb capabilities in ES|QL v9.4.0 labels Mar 11, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Hi @leontyevdv, I've created a changelog YAML for you.

leontyevdv and others added 2 commits March 11, 2026 15:44
When executing a query using the TS command with STATS dimension_field,
a _timeseries column is added in runtime and is taken into account when
validating the output.

It turns out that "LIMIT 0" is a corner case in which we replace
the entire plan with a different one (LocalRelation) so that
there is no TimeSeriesAggregate and a verification step fails.

Closes elastic#144024
@leontyevdv leontyevdv requested a review from dnhatn March 11, 2026 17:15
Copy link
Copy Markdown
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

LGTM. Can you add a csv test for this? Thanks Dima!

@leontyevdv
Copy link
Copy Markdown
Contributor Author

Can you add a csv test for this?

Thanks, Nhat! I added a couple of CSV tests.

@dnhatn
Copy link
Copy Markdown
Member

dnhatn commented Mar 11, 2026

Thanks Dima!

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
@leontyevdv leontyevdv enabled auto-merge (squash) March 12, 2026 13:42
@leontyevdv leontyevdv merged commit f95117f into elastic:main Mar 12, 2026
25 of 28 checks passed
szybia added a commit to szybia/elasticsearch that referenced this pull request Mar 12, 2026
…elocations

* upstream/main: (49 commits)
  CCS logging fixes (elastic#144070)
  Improve CPS cluster exclusion handling (elastic#143488)
  Remove snapshot condition now that node_reduce phase is in non-snapshot builds (elastic#144090)
  Drop deprecation warnings when updating a mapping in the cluster state applier (elastic#143884) (elastic#144040)
  Add ensureGreenAndNoInitializingShards helper (elastic#144044)
  Removed unnecessary applies_to blocks from deprecated query (elastic#144096)
  [CPS] Use single CrossProjectModeDecider instance (elastic#144030)
  Fix ESQL TS requests with LIMIT 0 (elastic#144031)
  ESQL: Remove `create` methods in aggs (elastic#144098)
  ES|QL: Refactor ChangeLimitOperator (elastic#144017)
  Add Paginated Hit Source Tests (elastic#142592)
  Fix test failure not preferred (elastic#144019)
  Remove serialization logic from EIS authorization response (elastic#144021)
  ESQL: CSV schema inference and parsing enhancements (elastic#144050)
  ESQL: Fix incorrectly optimized fork with nullify unmapped_fields (elastic#143030)
  Fix MMR release test using subqueries (elastic#144087)
  Refactoring `UserAgentPlugin` (elastic#140712)
  Drop non-finite samples in Prometheus remote write (elastic#144055)
  [TEST] Wait for internal inference indices to be created in authorization IT (elastic#143885)
  Disable ndjson datasource QA tests in release-tests (elastic#143992)
  ...
michalborek pushed a commit to michalborek/elasticsearch that referenced this pull request Mar 23, 2026
* Fix ESQL TS requests with LIMIT 0

When executing a query using the TS command with STATS dimension_field,
a _timeseries column is added in runtime and is taken into account when
validating the output.

It turns out that "LIMIT 0" is a corner case in which we replace
the entire plan with a different one (LocalRelation) so that
there is no TimeSeriesAggregate and a verification step fails.

Closes elastic#144024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >bug :StorageEngine/ES|QL Timeseries / metrics / PromQL / logsdb capabilities in ES|QL :StorageEngine/TSDB You know, for Metrics Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:StorageEngine v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Requests with LIMIT 0 are not executed when the TS command is used

4 participants