Skip to content

ES|QL: fix TBUCKET(n) on empty filter range - #146366

Merged
felixbarny merged 5 commits into
elastic:mainfrom
felixbarny:tbucket-empty-range
Apr 16, 2026
Merged

felixbarny merged 5 commits into
elastic:mainfrom
felixbarny:tbucket-empty-range

Conversation

@felixbarny

Copy link
Copy Markdown
Member

Closes #146354

When a query uses TBUCKET(n) (numeric bucket count) with a top-level request filter that covers a time range containing no indexed data, field-caps returns no matching indices and the analysis is retried without the filter. Previously the retry path called extractTimestampBounds(null, ...), returning null bounds, causing TBUCKET verification to fail with "numeric argument requires at least bounds on @timestamp".

The fix extracts TimestampBounds eagerly from the request filter before index resolution begins, then threads the pre-computed bounds through resolveIndicesAndAnalyze → analyzeWithRetry → analyzedPlan. On retry the same bounds are forwarded, so TBUCKET can determine its bucketing interval from the original filter's time range regardless of whether the index resolution used that filter.

@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team needs:triage Requires assignment of a team area label v9.5.0 labels Apr 15, 2026
@elasticsearchmachine elasticsearchmachine added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) and removed needs:triage Requires assignment of a team area label labels Apr 15, 2026
@elasticsearchmachine

Copy link
Copy Markdown
Collaborator

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

@elasticsearchmachine

Copy link
Copy Markdown
Collaborator

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

@github-actions

github-actions Bot commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

🔍 Preview links for changed docs

⏳ Building and deploying preview... View progress

This comment will be updated with preview links when the build is complete.

@github-actions

Copy link
Copy Markdown
Contributor

ℹ️ Important: Docs version tagging

👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version.

We use applies_to tags to mark version-specific features and changes.

Expand for a quick overview

When to use applies_to tags:

✅ At the page level to indicate which products/deployments the content applies to (mandatory)
✅ When features change state (e.g. preview, ga) in a specific version
✅ When availability differs across deployments and environments

What NOT to do:

❌ Don't remove or replace information that applies to an older version
❌ Don't add new information that applies to a specific version without an applies_to tag
❌ Don't forget that applies_to tags can be used at the page, section, and inline level

🤔 Need help?

@felixbarny felixbarny added v9.4.0 auto-backport Automatically create backport pull requests when merged v9.0.4 v8.19.15 v9.1.3 v9.2.3 v9.3.2 and removed >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.0.4 v9.1.3 v9.2.3 v9.4.0 v9.3.2 v8.19.15 labels Apr 15, 2026
@felixbarny felixbarny added >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) labels Apr 15, 2026

@bpintea bpintea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lgtm

@felixbarny
felixbarny merged commit f16c399 into elastic:main Apr 16, 2026
35 checks passed
@felixbarny
felixbarny deleted the tbucket-empty-range branch April 16, 2026 05:05
@elasticsearchmachine

Copy link
Copy Markdown
Collaborator

💔 Backport failed

The backport operation could not be completed due to the following error:

There are no branches to backport to. Aborting.

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 146366

@felixbarny

Copy link
Copy Markdown
Member Author

💚 All backports created successfully

Status Branch Result
✅ 9.4

Questions ?

Please refer to the Backport tool documentation

felixbarny added a commit to felixbarny/elasticsearch that referenced this pull request Apr 16, 2026
Closes elastic#146354

(cherry picked from commit f16c399)

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
felixbarny added a commit that referenced this pull request Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged backport pending >bug external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.4.0 v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ES|QL: TBUCKET(100) fails on empty range

3 participants