v.24.6Improvement
Second Argument of Round Functions Now Non-Const
The second argument (scale) of functionsround(),roundBankers(),floor(),ceil()andtrunc()can now be non-const. #64798 (Mikhail Gorshkov).
Why it matters
Previously, the scale argument for these rounding and truncation functions had to be a constant value, limiting flexibility in queries where the scale needed to vary dynamically. This enhancement enables users to apply different scale values per row or parameterize scale at runtime, making numeric rounding and truncation more versatile and adaptable to varied data processing needs.How to use it
Simply pass a non-constant expression as the second argument (scale) to the functionsround(), roundBankers(), floor(), ceil(), or trunc(). For example:SELECT round(value, dynamic_scale) FROM tablewhere
dynamic_scale can be a column or an expression evaluated at runtime.