-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Add output_format_float_precision setting to control decimal digits in float output #99199
Description
Float32/Float64 values are always serialised to text formats using the shortest round-trip representation (dragonbox), e.g. 39.645413178425954. There is no way to limit the number of output digits. The only workaround is wrapping every float column in ROUND() or toDecimalString(), which is tedious and modifies the query logic. A format-level setting like output_format_float_precision (default 0 = current behavior) would allow controlling this non-invasively.
This is also useful for benchmark suites like TPC-DS that produce reference answers with a fixed number of significant digits. Currently exact comparison is impossible without post-processing.
We also use ROUND(...) in many places in tests because float results differ between x86 and ARM architectures. In float-heavy tests, a single setting would be much more convenient than wrapping every expression.
SET output_format_float_precision = 6;
SELECT 1.0 / 3; -- 0.333333 instead of 0.3333333333333333