Backport Decimal precision limits to 0.6.x#274
Merged
ruslandoga merged 1 commit into0.6.xfrom May 5, 2026
Merged
Conversation
The adapter previously emitted Decimal64(scale) for every Decimal parameter regardless of value size and rendered the coefficient with Decimal.to_string/2 verbatim. Both the inline literal path (expr/4) and the parameter type path (param_type/1) are now guarded by a shared decimal_precision_and_scale!/1 helper that: - rejects non-finite values (NaN, Infinity) with ArgumentError - rejects scale > 76 with ArgumentError - rejects coefficients with more than 76 digits with ArgumentError - rejects computed precision > 76 with ArgumentError param_type/1 now emits Decimal(precision, scale) sized to the actual value (up to ClickHouse's Decimal256 ceiling of precision 76) instead of always Decimal64(scale). Rendering goes through a new decimal_to_string/1 helper that, when the upstream Decimal library exposes Decimal.to_string/3 with :max_digits, caps output at 77 digits and otherwise falls back to Decimal.to_string/2. Behavioral change for callers: Decimal parameters and inlined Decimal literals that exceed ClickHouse's Decimal limits, or that are NaN or Infinity, now raise ArgumentError at render time instead of silently producing malformed SQL. No new public option or API surface is added. (cherry picked from commit dc3ea20)
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.
Backports Decimal rendering and parameter typing bounds to the 0.6.x release branch.
Context: #271