Skip to content

Preserve float canonicalization in LowCardinality range inserts - #116637

Open
bobrik wants to merge 2 commits into
ClickHouse:masterfrom
bobrik:ivan/low-cardinality-float-fix
Open

bobrik wants to merge 2 commits into
ClickHouse:masterfrom
bobrik:ivan/low-cardinality-float-fix

Conversation

@bobrik

@bobrik bobrik commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Shared dictionaries from Native input can contain signed zero and multiple NaN payloads. Avoid sharing floating-point dictionaries so ColumnUnique canonicalizes these values during different-dictionary insertion.

This is a regression from: #115961

Changelog category (leave one):

  • Not for changelog

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


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

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Aug 27, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6788e93]

Summary: ✅


AI Review

Summary

This PR restores the pre-#115961 insertRangeFrom behavior for floating-point LowCardinality dictionaries and fixes value-based equality handling in the affected sort/permutation helpers. After reviewing the current diff, the touched code paths, the added tests, and all prior PR discussion, I do not see any remaining review findings in the current patch.

Final Verdict

✅ No new findings.

LLVM Coverage Report

Measured on commit 6788e93.

Metric Baseline Current Δ
Lines 89.00% 89.00% +0.00%
Functions 91.70% 91.80% +0.10%
Branches 81.30% 81.40% +0.10%

Changed lines: Changed C/C++ lines covered: 156/159 (98.11%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 27, 2026
Comment thread src/Columns/ColumnLowCardinality.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6788e93c7 with master c6aa6272e (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 9 s compile time in total, 7 of them have a recent master baseline.

Job report

@bobrik

bobrik commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

@alexey-milovidov good to merge?

@clickhouse-gh clickhouse-gh Bot added the comp-datatype-wrapper Type modifiers/wrappers (Nullable, LowCardinality, etc.). label Sep 4, 2026
@bobrik
bobrik force-pushed the ivan/low-cardinality-float-fix branch from 870f77a to 4c9a197 Compare September 6, 2026 00:18
@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog and removed pr-bugfix Pull request with bugfix, not backported by default labels Sep 6, 2026
Comment thread src/Columns/ColumnLowCardinality.cpp Resolved
@bobrik

bobrik commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

I added a commit to fix related issues that existed before #115961, but were flagged by the review bot.

Comment thread src/Columns/ColumnLowCardinality.cpp Resolved
@bobrik
bobrik force-pushed the ivan/low-cardinality-float-fix branch from 593e3ce to ed72070 Compare September 6, 2026 03:33
Comment thread src/Columns/ColumnLowCardinality.cpp Resolved
@bobrik
bobrik force-pushed the ivan/low-cardinality-float-fix branch from ed72070 to 5954518 Compare September 6, 2026 05:04
@bobrik
bobrik force-pushed the ivan/low-cardinality-float-fix branch 3 times, most recently from c85a8b6 to 8abb84c Compare September 13, 2026 02:17
@bobrik

bobrik commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Rebased to fix conflicts with #116870, which shrunk the diff a little bit.

@Avogar, you might be interested in merging this one.

Comment thread src/Columns/ColumnLowCardinality.cpp Resolved
Shared dictionaries reconstructed from on-disk `LowCardinality` dictionary
streams can contain signed zero and multiple NaN payloads.  Avoid sharing
floating-point dictionaries so `ColumnUnique` canonicalizes these values
during different-dictionary insertion.

This is a regression from: ClickHouse#115961
Shared floating-point dictionaries can contain separate indexes for `-0.0`,
`0.0`, and different NaN payloads even though sorting compares these values
as equal. This made `getPermutation` violate stable ordering and caused
`updatePermutation` to split equal ranges needed by subsequent sort keys.

Assign comparison-equal dictionary entries the same sort rank in both sorting
paths while keeping row sorting index-based. Canonicalize equivalent float
representations when estimating cardinality. Keep `hasEqualValues` index-based
because it also guards hash-based shortcuts.
@bobrik
bobrik force-pushed the ivan/low-cardinality-float-fix branch from 8abb84c to 6788e93 Compare September 13, 2026 02:47
@maxknv maxknv added the external Author is not a member of the ClickHouse organization label Nov 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-datatype-wrapper Type modifiers/wrappers (Nullable, LowCardinality, etc.). external Author is not a member of the ClickHouse organization pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants