{"record":{"id":"6cfa244a98c7ab5b","repo":"prestodb/presto","slug":"getobjectvalue-is-not-supported-for-timestamp","errorCode":null,"errorMessage":"getObjectValue is not supported for TIMESTAMP(","messagePattern":"getObjectValue is not supported for TIMESTAMP\\(","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/type/TimestampType.java","lineNumber":117,"sourceCode":"        if (precision == MAX_SHORT_PRECISION) {\n            // Preserve \"timestamp microseconds\" for the same reason.\n            return parseTypeSignature(StandardTypes.TIMESTAMP_MICROSECONDS);\n        }\n        // Other precisions use a numeric parameter; the type registry does not yet recognize the\n        // \"timestamp(p)\" string form, so these instances are created directly rather than parsed.\n        return new TypeSignature(StandardTypes.TIMESTAMP, TypeSignatureParameter.of((long) precision));\n    }\n\n    // Only p=3 and p=6 are supported; all other precisions throw UnsupportedOperationException.\n    // Support for p=0–2, p=4–5, and p=7–12 is planned for a follow-up change.\n    @Override\n    public Object getObjectValue(SqlFunctionProperties properties, Block block, int position)\n    {\n        if (block.isNull(position)) {\n            return null;\n        }\n        if (precision != DEFAULT_PRECISION && precision != MAX_SHORT_PRECISION) {\n            throw new UnsupportedOperationException(\n                    \"getObjectValue is not supported for TIMESTAMP(\" + precision + \")\");\n        }\n        TimeUnit unit = toTimeUnit(precision);\n        if (properties.isLegacyTimestamp()) {\n            return new SqlTimestamp(block.getLong(position), properties.getTimeZoneKey(), unit);\n        }\n        return new SqlTimestamp(block.getLong(position), unit);\n    }\n\n    // True when the value fits in a single long (p <= MAX_SHORT_PRECISION). Storage concept only —\n    // short precisions other than p=3 and p=6 are not yet registered in the type manager.\n    public boolean isShort()\n    {\n        return precision <= MAX_SHORT_PRECISION;\n    }\n\n    // Used to distinguish millisecond-precision timestamps (e.g. PartitionTable Iceberg partition\n    // value conversion, and future JDBC/ORC paths).","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/TimestampType.java#L99-L135","documentation":"Type.getObjectValue returns a Java object representation of a block value, but TimestampType only supports that materialization for the default precision (3) and MAX_SHORT_PRECISION (6). Other precisions (including long precisions 7-12) lack a supported Object representation, so UnsupportedOperationException is thrown.","triggerScenarios":"Calling getObjectValue(properties, block, position) on a TIMESTAMP(p) type where p is not 3 and not 6 (e.g. TIMESTAMP(0), TIMESTAMP(9), TIMESTAMP(12)) on a non-null position.","commonSituations":"Generic result-set materialization code in clients/JDBC layers or connectors that iterate all types and call getObjectValue without checking the precision; new long-precision TIMESTAMP columns appearing after a version upgrade.","solutions":["Use getLong / getSlice (the packed long representation) instead of getObjectValue for TIMESTAMP columns.","For p=3 or p=6 columns, no change is needed; for others convert via toEpochMillis/toEpochMicros when isShort() is true.","Switch queries/consumers to TIMESTAMP(3) or TIMESTAMP(6) if an Object value is required.","Check precision via type.getPrecision() before calling getObjectValue and handle unsupported precisions explicitly."],"exampleFix":"// before\nObject v = timestampType.getObjectValue(properties, block, position);\n// after\nObject v = (timestampType.getPrecision() == 3 || timestampType.getPrecision() == 6)\n        ? timestampType.getObjectValue(properties, block, position)\n        : timestampType.getLong(block, position);","handlingStrategy":"type-guard","validationCode":"if (type instanceof TimestampType\n        && ((TimestampType) type).getPrecision() != 3\n        && ((TimestampType) type).getPrecision() != 6) {\n    throw new IllegalStateException(\"Use getLong for TIMESTAMP(\" + ((TimestampType) type).getPrecision() + \")\");\n}","typeGuard":"boolean supportsObjectValue(TimestampType t) { return t.getPrecision() == 3 || t.getPrecision() == 6; }","tryCatchPattern":"try {\n    value = timestampType.getObjectValue(props, block, pos);\n} catch (UnsupportedOperationException e) {\n    value = timestampType.getLong(block, pos); // packed representation\n}","preventionTips":["Check getPrecision() before any getObjectValue call in generic type-handling code.","Standardize schemas on TIMESTAMP(3) or TIMESTAMP(6) where Object materialization is needed.","Handle long precisions (7-12) explicitly in connector readers."],"tags":["presto","unsupported-operation","timestamp-precision"],"backgroundTag":"unsupported-operation","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"}