Repository navigation
fix(clickhouse): write number literals that read back exactly - #40
Merged
Merged
Conversation
Two spellings did not round-trip through ClickHouse's SQL parser:
- a subnormal float (`5e-324`) is a SYNTAX_ERROR, and parsed from text
(`toFloat64('5e-324')`) it flushes to 0; it is now written from its
IEEE bits as `reinterpretAsFloat64(toUInt64(<bits>))`.
- a whole double past 2^53 printed as its shortest decimal
(`44812297868494010`) is parsed as an exact integer the double is not
(…008), so `WHERE x = value` missed the row; it is now written as the
double's own integer value.
Both apply to column literals, `lit`, and untyped number operands. Found by
the literal fuzzer; its known-issue entry is removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Makisuo
added this pull request to stack #46
October 23, 2026 00:18
This was referenced Oct 23, 2026
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.
ClickHouse number literals now read back as exactly the value given.
5e-324) was aSYNTAX_ERROR; text parsing (toFloat64('5e-324')) flushes it to 0. It is written from its bits:reinterpretAsFloat64(toUInt64(1)).44812297868494010) is parsed by ClickHouse as an exact integer the double is not (…008), soWHERE x = valuemissed the row. It is written as the double's own integer value.Applies to column literals,
lit, and untyped number operands. While here: the fuzzer's earlier "decimal float literals are 1 ULP off" lead was wrong — a bit-exact check showsString(value)round-trips; ClickHouse's text float parser (JSON input,toFloat64('…')) is the imprecise one, so the Float64 reference row is built from bits.Verification: unit tests in
literal.test.ts; Float64/Int64/UInt64 literal fuzz in strict mode at 50× against ClickHouse 25.8 (2000 values per path); full suite.Stack (merge bottom-up):
🤖 Generated with Claude Code