Repository navigation
fix(clickhouse): LimitRanking treats -0 and 0 as the same value - #25
Merged
Merged
Conversation
The 2026-10-31 master nightly (SQLancer (arm_asan_ubsan), database176) reported a negative-LIMIT mismatch at checkNegativeLimitTail. t0 held two rows that differ only in a Float column: (18446744072471263932, -0, 0) and (18446744072471263932, 0, 0). -0 = 0, so 'ORDER BY c0, c1, c2' does not order these two rows, and 'LIMIT -n' and the reversed 'LIMIT n' may legally pick different ones. The oracle compares rows by their toString text, where they print as -0 and 0. read now rewrites every -0 token bounded by tuple, array or map delimiters to 0 before the rows are compared, which also covers floats nested in arrays and maps. A quoted string '-0' is not touched. NaN needs no such treatment, since ClickHouse prints every NaN as nan. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=6983f5a16d92c831f350e3aa9995a7a1d6f08298&name_0=NightlySQLancer&name_1=SQLancer%20%28arm_asan_ubsan%29 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Ok. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 2026-10-31 master nightly (SQLancer (arm_asan_ubsan),
database176) reported aLimitRankingnegative-LIMIT mismatch atcheckNegativeLimitTail.After replaying the reproducer,
t0holds two rows that differ only in a float column:(18446744072471263932, -0, 0)(18446744072471263932, 0, 0)-0 = 0, soORDER BY c0, c1, c2does not order these two rows.LIMIT -nand the reversedLIMIT ncan legally pick different ones. The oracle compares rows by theirtoStringtext, where the two rows print as-0and0, so it reported a mismatch that is not a ClickHouse bug.readnow rewrites every-0token bounded by tuple, array or map delimiters to0before rows are compared. This also covers floats nested inArrayandMap, which a per-column-type cast would miss. Quoted strings such as'-0', and values such as-0.5or-01, are untouched. NaN needs no such treatment, because ClickHouse prints every NaN asnan. I checked the delimiters againsttoString(tuple(-0., 0., [-0., 1], -nan, nan, map('a', -0.), '-0', -0.5, toBFloat16(-0.)))on a 26.11 build, which prints(-0,0,[-0,1],nan,nan,{\'a\':-0},\'-0\',-0.5,-0).Checked:
mvn verify -DskipTests=true -Djacoco.skip=truepasses. I also unit-checked the regex against the failing row, adjacent(-0,-0), and nested arrays and maps. Per the repo's rules I did not run sqlancer locally.🤖 Generated with Claude Code