{"record":{"id":"b44a03e273b23985","repo":"prestodb/presto","slug":"timestamp-exceeds-maximum-supported-value-value","errorCode":null,"errorMessage":"Timestamp exceeds maximum supported value, value: %s truncatedNanos: %s.","messagePattern":"Timestamp exceeds maximum supported value, value: (.+?) truncatedNanos: (.+?)\\.","errorType":"exception","errorClass":"TimestampOutOfBoundsException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/reader/ApacheHiveTimestampDecoder.java","lineNumber":77,"sourceCode":"            throw new TimestampOutOfBoundsException(errorMessage, e);\n        }\n    }\n\n    // Add truncated nanos to seconds value\n    private static long getValueWithNanos(boolean enableMicroPrecision, long value, long truncatedNanos)\n    {\n        if (!enableMicroPrecision) {\n            // This can overflow/underflow, but to maintain backward compatibility this is not bounds checked.\n            return value + truncatedNanos;\n        }\n        try {\n            // Overflow/underflow is detected and the code will raise error.\n            return Math.addExact(value, truncatedNanos);\n        }\n        catch (ArithmeticException e) {\n            String errorMessage = String.format(\"Timestamp exceeds maximum supported value, value: %s truncatedNanos: %s.\",\n                    value, truncatedNanos);\n            throw new TimestampOutOfBoundsException(errorMessage, e);\n        }\n    }\n\n    // This comes from the Apache Hive ORC code\n    private static int parseNanos(long serialized)\n    {\n        int zeros = ((int) serialized) & 0b111;\n        int result = (int) (serialized >>> 3);\n        if (zeros != 0) {\n            for (int i = 0; i <= zeros; ++i) {\n                result *= 10;\n            }\n        }\n        return result;\n    }\n}\n","sourceCodeStart":59,"sourceCodeEnd":94,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/ApacheHiveTimestampDecoder.java#L59-L94","documentation":"Thrown by ApacheHiveTimestampDecoder.getValueWithNanos when Math.addExact overflows adding truncated nanos to the seconds value. It indicates the composed timestamp cannot be represented in Presto's internal long-based timestamp representation, and is rethrown as TimestampOutOfBoundsException.","triggerScenarios":"decodeTimestamp producing a value so close to Long.MAX_VALUE (or MIN_VALUE) that adding the nanos component overflows — practically only with seconds already near the representable limit.","commonSituations":"ORC timestamps at the extreme edge of the supported range; negative pre-epoch timestamps near Long.MIN_VALUE combined with nanos handling; misaligned unit scaling between writer and reader options.","solutions":["Keep timestamp data within the supported range (avoid values near the internal long limits).","Normalize extreme values in the ETL layer before writing ORC files.","Catch TimestampOutOfBoundsException and substitute a sentinel/null in the reading application.","Verify enableMicroPrecision/unitsPerSecond options match how the file was written to avoid inflated values."],"exampleFix":"// before\nTimestamp value = decoder.decodeTimestamp(...); // may throw\n// after\ntry { value = decoder.decodeTimestamp(...); } catch (TimestampOutOfBoundsException e) { value = null; }","handlingStrategy":"try-catch","validationCode":"// ensure seconds+nanos composition stays within long range before decode\nif (secondsWithBase >= MAX_SECONDS - 1) throw new IllegalArgumentException(\"timestamp too large\");","typeGuard":null,"tryCatchPattern":"try { ts = decoder.decodeTimestamp(...); } catch (TimestampOutOfBoundsException e) { ts = null; }","preventionTips":["Keep timestamps well inside the supported long range","Normalize out-of-range data in upstream ETL","Match enableMicroPrecision/unitsPerSecond options to the file encoding"],"tags":["orc","timestamp","overflow","presto"],"backgroundTag":"timestamp-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"}