Decimal.set(unscaled, precision, scale) reports the previous value instead of the rejected one on overflow

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major
    • None
    • Affects Version/s: 3.5.8, 4.2.0, 4.3.0, 4.1.3, 4.0.4, 4.4.0
    • Component/s: SQL

      `Decimal.set(unscaled: Long, precision: Int, scale: Int)` throws `unscaledValueTooLargeForPrecisionError(this, precision, scale)` after `setOrNull` returns null. `setOrNull` returns before writing any field, so `this` still holds its previous value, which is 0 for a new `Decimal`. For example, `Decimal(123456L, 3, 0)` throws "0 cannot be represented as Decimal(3, 0)". Callers include `MakeDecimal` under ANSI and `AvroDeserializer.createDecimal`. The error should build the value from `unscaled` and `scale`.

      Found in the review of SPARK-60119.

            Assignee:
            Unassigned
            Reporter:
            L. C. Hsieh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: