Skip to content

Fix read-in-order skipping the sort for Decimal/DateTime64 compared with a float, arrays without a common type and Tuple(Dynamic) compared with a string - #126019

Merged
NIKTONIKTO717 merged 2 commits into
masterfrom
fix-125179
Oct 16, 2026
Merged

NIKTONIKTO717 merged 2 commits into
masterfrom
fix-125179

Conversation

@NIKTONIKTO717

@NIKTONIKTO717 NIKTONIKTO717 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Closes: #125179
Closes: #125535
Related: #123677
Related: #125378

Read-in-order treated a column as fixed when equals can match several values that sort differently: Decimal/DateTime64/Time64 wider than Decimal32 vs a float (compared in Float64), arrays without a common type (compared element by element), and a Tuple with Variant/Dynamic vs a string literal (parsed into the tuple type, whose Variant/Dynamic elements compare across stored types). equalsMatchesSeveralValues now detects these, so such queries sort the matching rows. Tests are added to 05321_read_in_order_string_vs_fixed_string_constant.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixed unsorted or wrongly grouped results of ORDER BY, LIMIT BY and GROUP BY in order when a Decimal or DateTime64 column is compared with a float, an Array column with an array of an incompatible type, or a Tuple column with a Variant/Dynamic element with a string literal.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/126019]

Version info

  • Merged into: 26.11.1.74-master (included in 26.11 and later)

@yariks5s yariks5s self-assigned this Oct 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b5a3715]

Summary: ✅


AI Review

Summary

PR #126019 prevents read-in-order optimizations from treating an expression as fixed when equals can match values that sort differently: wide decimal types compared with floats, arrays without a common type, and tuples containing Variant or Dynamic compared with string literals. Review of head b5a3715f11fb4292a899be2c490e6f8fe2656e96, its callers, comparison implementations, regression coverage, and all prior discussion found no actionable correctness or safety issues.

Missing context / blind spots
  • ⚠️ Runtime validation remains unconfirmed. No local build or executable was available, and the current-head workflow reports targeted stateless tests and functional bugfix validation as pending. A completed run of 05321_read_in_order_string_vs_fixed_string_constant would close this gap.
Final Verdict

Status: ✅ Approve. No inline findings. Runtime CI results remain pending.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... labels Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

3 participants