Repository navigation
Add a setting to force print decimal point in text formats when printing floats - #62614
Conversation
alexey-milovidov
left a comment
There was a problem hiding this comment.
I didn't see often when it is called "period".
"Decimal point" is more common.
|
It should apply to Decimal as well. |
|
Dear @alexey-milovidov, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
…force_period # Conflicts: # src/Core/Settings.h # src/Formats/FormatFactory.cpp # src/Formats/FormatSettings.h # src/Functions/FunctionsJSON.h # src/IO/WriteHelpers.h
… to Decimal This completes the `output_format_approximate_numbers_with_decimal_point` setting after merging `master`: - Move the float fast-path logic to the rewritten `writeFloatTextFastPath` in `WriteHelpers.cpp`, threading `force_decimal_point` through all of its integer-producing branches. The earlier draft only handled the two `isIntegerInRepresentableRange` branches and appended the point at the wrong offset (`buffer[1]` instead of the end); both are fixed here, and the rounding fast paths (`writeFloatTextFastPathFloat64Rounded` / `...Float32Rounded`) now also emit the point for large whole-number floats. Special values (`inf`/`nan`) and fractional/scientific outputs go through the `zmij` branch and are never affected. - Declare the setting in `FormatFactorySettings.h` (its modern location) with a clearer description, and register it in `SettingsChangesHistory.cpp`. - Apply the setting to `Decimal` as well, per review feedback: a whole-number Decimal value now prints a trailing decimal point when no fractional digits are written. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [bdcaa74] Summary: ✅
AI ReviewSummaryThis PR adds Final VerdictStatus: ✅ Approve |
`SerializationDecimal::serializeTextJSON` delegated to `serializeText`, so `output_format_approximate_numbers_with_decimal_point` also affected JSON `Decimal` output. With the default `output_format_json_quote_decimals = 0`, `SELECT 1::Decimal(10, 2) FORMAT JSONEachRow` would emit a bare `1.`, which is not a valid JSON number. Inline the value serialization in `serializeTextJSON` without forcing the decimal point, mirroring `SerializationNumber::serializeTextJSON` which goes through `writeJSONNumber` and never forces the point either. Extend the test with JSON regression cases for both quoted and unquoted `Decimal` output. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The feature-docs CI hook accepts a `*Settings.cpp` change containing the settings-declaration macro as documentation for a new feature, because the autogenerated settings docs are produced from the embedded `DECLARE(...)` description strings. Format settings, however, are declared in the header `FormatFactorySettings.h`, which the suffix rule does not cover, so adding a new format setting failed the check even though it carries an embedded description string. List the header explicitly alongside `ProfileEvents.cpp` and `CurrentMetrics.cpp`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…force_period # Conflicts: # src/Core/FormatFactorySettings.h # src/DataTypes/Serializations/SerializationNumber.cpp # src/Formats/FormatFactory.cpp # src/Formats/FormatSettings.h # src/IO/WriteHelpers.cpp
|
Picked this up via Merged
I integrated Addressed the review thread about JSON CI:
Built clean and verified locally: |
…entation path `force_decimal_point` previously fired only for the `itoa`-based fast paths in `writeFloatTextFastPath`, tracked via an `integer_representation` flag. But the `zmij` shortest-representation branch can also emit a bare integer for large magnitudes outside the itoa ranges, e.g. `toFloat32(1.23e20)` -> `123000000000000000000`. Such values kept `integer_representation = false` and so missed the forced trailing decimal point. Replace the branch-tracking flag with the same byte-scan predicate already used by the `output_format_float_precision` path: append `.` only when the emitted representation contains no `.`, `e`, or `E`, guarded by `isFinite` so `inf`/`nan` are left untouched. Add a regression for large `Float32`/`Float64` values printed through the shortest-representation path. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Continued via Merged Fixed the open Bugbot thread ( Built clean; |
…master The test number 04309 was taken by 04309_distributed_aggregation_persisted_exchange and 04309_explain_insert_format on master. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Merged Renumbered the test Rebuilt and verified the feature end-to-end against the fresh binary — all reference cases pass, including the special-value ( The only red was |
|
Merged Analysis of the CI failures on the previous run (
@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=62614&sha=bf7b0ecfcdf3719e6017cf449092bcf6959986b1&name_0=PR&name_1=BuzzHouse%20%28arm_asan_ubsan%29 (UBSan null pointer in |
|
@alexey-milovidov investigated. This BuzzHouse UBSan trap (STID 2791-2e42) is a deterministic trunk bug, not fuzzer AST corruption, and your read is correct: it pre-exists on master and is unrelated to this PR. Root cause: Fix status: I opened a separate fix PR #107079 (replace the empty stub with a null For this PR: re-merging current master (which you have done) picks up the removal, so the BuzzHouse UBSan will not recur here. Forward guard if #106020 ever re-lands: |
|
Continued via The branch is up to date (merge-base with
Re-ran the failed jobs to clear the timeout flakes. |
|
Continued via Merged All 5 review threads are resolved and the previous CI run was fully green (141 passed, 0 failed). Fresh CI will run on the re-merged head |
|
@qoega, you made a commit from "Ubuntu" instead of your real name. We will need to rewrite it and do push -f. |
…point_in_float_and_decimal The previous name `output_format_approximate_numbers_with_decimal_point` was misleading: the values being formatted are not approximate, and `Decimal` numbers in particular are precise. Rename the setting to `output_format_always_write_decimal_point_in_float_and_decimal`, which describes exactly what it does, and rename the corresponding `FormatSettings` field to `always_write_decimal_point_in_float_and_decimal`. The setting has not been released yet, so the `SettingsChangesHistory` entry is renamed in place rather than aliased. The stateless test is renamed accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When `output_format_always_write_decimal_point_in_float_and_decimal` is enabled, the float-formatting fast path checked whether the produced text already contained a `.`, `e`, or `E` before appending a trailing decimal point. This used three separate `memchr` calls, each rescanning the whole buffer. Replace them with a single `find_first_symbols<'.', 'e', 'E'>` scan in both places (the `writeFloatTextFastPath` integer path and the `write_representation` lambda on the precision path), matching the value against the end pointer. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
99ab8af to
860fbe7
Compare
… in the test The regression test for `output_format_always_write_decimal_point_in_float_and_decimal` only exercised the default `output_format_float_precision = 0` fast path. The precision path in `writeFloatText` appends the forced decimal point in a separate place (the `write_representation` lambda), and `ToFixed` can strip a value down to a bare integer before that point is applied. Added three cases with both settings enabled: - a whole-valued `Float64` printed via the shortest representation -> `1.`; - a value that rounds to a whole number at the requested precision, so `ToFixed` strips it to a bare integer -> `2.` (this is the case the forced point must cover); - a fractional value formatted through `ToFixed` -> unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 97/97 (100.00%) | Lost baseline coverage: none · Uncovered code |
The branch was 1106 commits behind master (merge base 2026-06-14) and CI was red only on known master-wide flakes; merging to refresh CI against current master. The merge is textually clean: master's touches to the shared format files are additive (the embedded-format-documentation refactor in #106181 adds an optional setDocumentation API without changing the registration signatures, plus the new output_format_always_write_decimal_point_in_float_and_decimal setting from #62614), and the native Arrow IPC code under ArrowIPC/ is untouched by master. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The branch was 1106 commits behind master (merge base 2026-06-14) and CI was red only on known master-wide flakes; merging to refresh CI against current master. The merge is textually clean: master's touches to the shared format files are additive (the embedded-format-documentation refactor in ClickHouse#106181 adds an optional setDocumentation API without changing the registration signatures, plus the new output_format_always_write_decimal_point_in_float_and_decimal setting from ClickHouse#62614), and the native Arrow IPC code under ArrowIPC/ is untouched by master. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Added a setting
output_format_always_write_decimal_point_in_float_and_decimalto always print a decimal point for floating-point andDecimalnumbers in text formats, even when the value is a whole number. For example, output1.instead of1. Disabled by default.Documentation entry for user-facing changes
Modify your CI run:
NOTE: If your merge the PR with modified CI you MUST KNOW what you are doing
NOTE: Checked options will be applied if set before CI RunConfig/PrepareRunConfig step
Include tests (required builds will be added automatically):
Exclude tests:
Extra options:
Only specified batches in multi-batch jobs:
Version info
26.6.1.840