{"record":{"id":"db9934ad5d501d29","repo":"prestodb/presto","slug":"numeric-value-out-of-range","errorCode":"NUMERIC_VALUE_OUT_OF_RANGE","errorMessage":"Value out of range: '%s' ('%sB')","messagePattern":"Value out of range: '(.+?)' \\('(.+?)B'\\)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/scalar/DataSizeFunctions.java","lineNumber":66,"sourceCode":"                valueLength++;\n            }\n            else {\n                break;\n            }\n        }\n\n        if (valueLength == 0) {\n            throw invalidDataSize(dataSize);\n        }\n\n        BigDecimal value = parseValue(dataSize.substring(0, valueLength), dataSize);\n        Unit unit = Unit.parse(dataSize.substring(valueLength), dataSize);\n        BigInteger bytes = value.multiply(unit.getFactor()).toBigInteger();\n        try {\n            return encodeUnscaledValue(bytes);\n        }\n        catch (ArithmeticException e) {\n            throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, format(\"Value out of range: '%s' ('%sB')\", dataSize, bytes));\n        }\n    }\n\n    private static BigDecimal parseValue(String value, String dataSize)\n    {\n        try {\n            return new BigDecimal(value);\n        }\n        catch (NumberFormatException e) {\n            throw invalidDataSize(dataSize);\n        }\n    }\n\n    private static PrestoException invalidDataSize(String dataSize)\n    {\n        return new PrestoException(INVALID_FUNCTION_ARGUMENT, format(\"Invalid data size: '%s'\", dataSize));\n    }\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/scalar/DataSizeFunctions.java#L48-L84","documentation":"parse_data_size(text) parses strings like '10GB' into a byte count. When the computed byte value exceeds what can be encoded as a BIGINT, the ArithmeticException from encoding is rethrown as NUMERIC_VALUE_OUT_OF_RANGE showing both the input and the byte total.","triggerScenarios":"parse_data_size('10EB')-style inputs where value * unit factor overflows the maximum BIGINT (about 9.2 exabytes), or huge numeric parts like '99999999999999999999B'.","commonSituations":"Parsing user/config-provided size strings without bounds (e.g. quota settings typed as '1000000PB'); unit confusion between decimal and binary units in oversized specs.","solutions":["Reduce the value or use a smaller unit so the result fits in BIGINT (< ~9.22EB total bytes)","Validate the input against a max size before parsing","Catch the NUMERIC_VALUE_OUT_OF_RANGE condition in callers and surface a clear config error"],"exampleFix":"// before\nSELECT parse_data_size('10EB'); -- overflows bigint\n// after\nSELECT parse_data_size('9EB'); -- fits in bigint\n","handlingStrategy":"validation","validationCode":"if (bytes > Long.MAX_VALUE) throw new IllegalArgumentException(\"out of range\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bound size strings below ~9.22EB"],"tags":["sql","scalar-function","overflow","datasize"],"backgroundTag":"bigint-overflow","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"}