{"record":{"id":"6a8d0f3181985231","repo":"prestodb/presto","slug":"decimal-overflow","errorCode":null,"errorMessage":"Decimal overflow","messagePattern":"Decimal overflow","errorType":"exception","errorClass":"ArithmeticException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/type/UnscaledDecimal128Arithmetic.java","lineNumber":1650,"sourceCode":"        setNegativeLong(decimal, high, negative);\n    }\n\n    public static Slice pack(long low, long high, boolean negative)\n    {\n        Slice decimal = unscaledDecimal();\n        pack(low, high, negative, decimal);\n        return decimal;\n    }\n\n    public static void pack(long low, long high, boolean negative, Slice result)\n    {\n        setRawLong(result, 0, low);\n        setRawLong(result, 1, high | (negative ? SIGN_LONG_MASK : 0));\n    }\n\n    public static void throwOverflowException()\n    {\n        throw new ArithmeticException(\"Decimal overflow\");\n    }\n\n    public static int getInt(Slice decimal, int index)\n    {\n        int value = getRawInt(decimal, index);\n        if (index == SIGN_INT_INDEX) {\n            value &= ~SIGN_INT_MASK;\n        }\n        return value;\n    }\n\n    public static long getLong(Slice decimal, int index)\n    {\n        long value = getRawLong(decimal, index);\n        if (index == SIGN_LONG_INDEX) {\n            return unpackUnsignedLong(value);\n        }\n        return value;","sourceCodeStart":1632,"sourceCodeEnd":1668,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/UnscaledDecimal128Arithmetic.java#L1632-L1668","documentation":"throwOverflowException is raised when the result of a decimal operation (multiply, add, divide, rescale, etc.) exceeds the precision/scale capacity of the target unscaled decimal representation — decimal overflow at runtime.","triggerScenarios":"Thrown at presto-common/src/main/java/com/facebook/presto/common/type/UnscaledDecimal128Arithmetic.java:1650 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Cast operands to a DECIMAL with higher precision/scale before the operation","Reduce the magnitude of operands","Rewrite the expression to avoid the intermediate overflow"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}