Skip to content

ES|QL: Implement first/last_over_time for tdigest#143832

Merged
JonasKunz merged 6 commits intoelastic:mainfrom
JonasKunz:tdigest-first-last-over-time
Mar 10, 2026
Merged

ES|QL: Implement first/last_over_time for tdigest#143832
JonasKunz merged 6 commits intoelastic:mainfrom
JonasKunz:tdigest-first-last-over-time

Conversation

@JonasKunz
Copy link
Copy Markdown
Contributor

@JonasKunz JonasKunz commented Mar 9, 2026

Adds the missing first_/last_over_time ES|QL implementations for T-Digest.
Closes #142677.

Note that this PR adds the implementation for both the grouping and the ungrouping variants. However, in TSDB we only use the grouping code path, so the ungrouping one is effectively dead code, just like for first/last_over_time on exponential histograms.

If desired, I could remove this dead code and replace it with UnsupportedOperationExceptions where needed.
The dead code would become useful if we decide to implement first/last, which we currently don't support.

@JonasKunz JonasKunz added >enhancement :StorageEngine/ES|QL Timeseries / metrics / PromQL / logsdb capabilities in ES|QL labels Mar 9, 2026
@elasticsearchmachine elasticsearchmachine added v9.4.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Mar 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

ℹ️ 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?

}

public static void combine(ExponentialHistogramStates.WithLongSingleState current, ExponentialHistogram value, long timestamp) {
if (timestamp < current.longValue()) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is currently dead code, which is why this mistake didn't show up. If desired, we could remove the dead code and replace it with UnsupportedOperationExceptions.

@JonasKunz JonasKunz marked this pull request as ready for review March 9, 2026 13:11
@JonasKunz JonasKunz requested a review from a team as a code owner March 9, 2026 13:11
@JonasKunz JonasKunz requested a review from kkrik-es March 9, 2026 13:11
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@kkrik-es kkrik-es requested a review from dnhatn March 9, 2026 14:16
Copy link
Copy Markdown
Member

@kkrik-es kkrik-es left a comment

Choose a reason for hiding this comment

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

It'd be nice if Nhat can take a quick look too.

@JonasKunz JonasKunz self-assigned this Mar 9, 2026
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. Thanks @JonasKunz

@JonasKunz JonasKunz enabled auto-merge (squash) March 10, 2026 08:31
@JonasKunz JonasKunz merged commit ea3365c into elastic:main Mar 10, 2026
36 checks passed
szybia added a commit to szybia/elasticsearch that referenced this pull request Mar 10, 2026
…locations

* upstream/main: (126 commits)
  Update KnnIndexTester to use more settings from datasets (elastic#143869)
  fix: dynamic template vector array is overridden by automatic dense_vector mapping (elastic#143733)
  ES|QL: Don't reuse the same alias for _fork column (elastic#143909)
  Close and initialize clients after each node upgrade in logsdb rolling upgrade tests. (elastic#143823)
  ESQL: Added GroupedTopNOperator for LIMIT BY, compute only (elastic#143476)
  Handle views in ResolveIndexAction (elastic#143561)
  Improve reindex rethrottle API in stateless (elastic#143771)
  Use a copy of the SearchExecutionContext for each Percolator execution (elastic#142765)
  Log the stacktrace when we encounter a deprecation warning for `default_metric` (elastic#143929)
  ESQL: evaluate ReferenceAttributes to potentially FieldAttributes for full-text functions restriction (elastic#143893)
  Add ClusterStateSerializationStats Serializatation Tests (elastic#142703)
  Adds Coordination Diagnostics Tests (elastic#142709)
  Upgrade Elasticsearch to Apache Lucene 10.4 (elastic#141882)
  ESQL: Add configurable bracket-based multi-value support for CSV reader (elastic#143890)
  time series es819 binary dv use up to a 1mb block size (elastic#143049)
  Dynamically enable / disable plugins in correspondence to stateless mode. (elastic#142147)
  ES|QL: Implement first/last_over_time for tdigest (elastic#143832)
  Document CHANGE_POINT limitation (elastic#143877)
  Fix OperationsOnSeqNoDisabledIndicesIT (elastic#143892)
  [Test] Test that sequence numbers are not pruned with retention lease (elastic#143825)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add missing ES|QL aggregations for T-Digest

4 participants