File tree Expand file tree Collapse file tree
src/databricks/sql/parameters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -728,6 +728,9 @@ def __init__(
728728 # DECIMAL can never have scale > precision, so this can only be a call
729729 # written for the old convention: keep it working for now (swap the
730730 # arguments) but warn so callers migrate before this becomes an error.
731+ # scale == precision is deliberately *not* handled here: it reads the
732+ # same under both conventions, so it gets the SQL meaning and is widened
733+ # like any correctly ordered call (documented in the CHANGELOG).
731734 warnings .warn (
732735 "DecimalParameter received scale ({}) > precision ({}); interpreting the "
733736 "arguments using the legacy (swapped) convention as DECIMAL({},{}). "
Original file line number Diff line number Diff line change @@ -214,6 +214,17 @@ def test_decimal_correct_order_with_more_fractional_digits_is_widened():
214214 assert p ._cast_expr () == "DECIMAL(6,4)"
215215
216216
217+ def test_decimal_scale_equal_to_precision_is_widened_without_warning ():
218+ """scale == precision means the same in both conventions, so it is not treated as
219+ a legacy call: it gets the SQL meaning and is widened like any correctly ordered
220+ call (earlier releases bound DECIMAL(2,2) and rounded to 0.12). See CHANGELOG."""
221+ with warnings .catch_warnings ():
222+ warnings .simplefilter ("error" )
223+ p = DecimalParameter (Decimal ("0.1234" ), scale = 2 , precision = 2 )
224+ assert not p ._legacy_swapped
225+ assert p ._cast_expr () == "DECIMAL(4,4)"
226+
227+
217228@pytest .mark .parametrize (
218229 "scale,precision,match" ,
219230 (
You can’t perform that action at this time.
0 commit comments