Skip to content

fix(tdigest): preserve stored min and max when merging - #525

Merged
leerho merged 1 commit into
apache:masterfrom
jaideeppyne:fix/tdigest-merge-minmax
Sep 17, 2026
Merged

leerho merged 1 commit into
apache:masterfrom
jaideeppyne:fix/tdigest-merge-minmax

Conversation

@jaideeppyne

Copy link
Copy Markdown
Contributor

Summary

  • Copy the stored min_ / max_ from the other digest in tdigest::merge before compressing the combined centroid list.
  • Add a regression that merges a deserialized image whose stored min/max sit strictly outside the extreme centroid means.

Why

merge previously re-derived extrema from the extreme centroid means. That is exact only when those centroids have unit weight. Deserialized images (and the reference implementation format) can have weighted tails, so min/max drifted inward and rank/quantile tail interpolation used the wrong endpoints.

Same defect as apache/datasketches-rust#277.

Validation

  • tdigest_test including merge preserves deserialized min max with weighted tails and the full [tdigest] suite (49 cases).

Merging a digest whose extreme centroids have weight greater than one
re-derived min and max from those centroid means. Copy the stored extrema
from the other digest first so rank and quantile tail interpolation stay
correct, especially for deserialized images.

@leerho leerho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for finding and fixing this!

@leerho
leerho merged commit 7aaa0bb into apache:master Sep 17, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants