{"record":{"id":"41692ae64dae2ef8","repo":"prestodb/presto","slug":"division-by-zero","errorCode":null,"errorMessage":"Division by zero","messagePattern":"Division by zero","errorType":"exception","errorClass":"ArithmeticException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/type/UnscaledDecimal128Arithmetic.java","lineNumber":1579,"sourceCode":"\n        long remainder = getLong(decimal, 1);\n        long high = remainder / divisor;\n        remainder %= divisor;\n\n        remainder = (getInt(decimal, 1) & LONG_MASK) + (remainder << 32);\n        int z1 = (int) (remainder / divisor);\n        remainder %= divisor;\n\n        remainder = (getInt(decimal, 0) & LONG_MASK) + (remainder << 32);\n        int z0 = (int) (remainder / divisor);\n\n        pack(result, z0, z1, high, isNegative(decimal));\n        return (int) (remainder % divisor);\n    }\n\n    private static void throwDivisionByZeroException()\n    {\n        throw new ArithmeticException(\"Division by zero\");\n    }\n\n    private static void multiplyShiftDestructive(Slice decimal, Slice multiplier, int rightShifts)\n    {\n        int[] product = new int[NUMBER_OF_INTS * 2];\n        Slice multiplicationResult = Slices.wrappedIntArray(product);\n        multiply256(decimal, multiplier, multiplicationResult);\n        shiftRightArray8(product, rightShifts, decimal);\n    }\n\n    private static void setNegative(Slice decimal, boolean negative)\n    {\n        setRawInt(decimal, SIGN_INT_INDEX, getInt(decimal, SIGN_INT_INDEX) | (negative ? SIGN_INT_MASK : 0));\n    }\n\n    private static void setNegativeInt(Slice decimal, int v3, boolean negative)\n    {\n        if (v3 < 0) {","sourceCodeStart":1561,"sourceCodeEnd":1597,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/UnscaledDecimal128Arithmetic.java#L1561-L1597","documentation":"throwDivisionByZeroException is the central helper raised whenever a DECIMAL division or modulo has a zero divisor; it fires from the unscaled-128 arithmetic paths when users execute decimal division by zero.","triggerScenarios":"Thrown at presto-common/src/main/java/com/facebook/presto/common/type/UnscaledDecimal128Arithmetic.java:1579 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Filter or NULL out zero divisors before the division","Use NULLIF(divisor, 0) in SQL to avoid the divide-by-zero path"],"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"}