{"record":{"id":"955d56f348ededa8","repo":"prestodb/presto","slug":"type-not-supported-as-partition-column","errorCode":null,"errorMessage":"Type not supported as partition column: ","messagePattern":"Type not supported as partition column: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergPageSink.java","lineNumber":556,"sourceCode":"        if (type instanceof DoubleType) {\n            return type.getDouble(block, position);\n        }\n        if (type instanceof VarbinaryType) {\n            return type.getSlice(block, position).getBytes();\n        }\n        if (type instanceof VarcharType) {\n            return type.getSlice(block, position).toStringUtf8();\n        }\n        if (type instanceof TimestampType) {\n            // Iceberg expects epoch-microseconds. toEpochMicros converts both TIMESTAMP (p=3, millis)\n            // and TIMESTAMP_MICROSECONDS (p=6, micros) to the required unit.\n            return ((TimestampType) type).toEpochMicros(type.getLong(block, position));\n        }\n        if (type instanceof TimeType) {\n            long time = type.getLong(block, position);\n            return MILLISECONDS.toMicros(time);\n        }\n        throw new UnsupportedOperationException(\"Type not supported as partition column: \" + type.getDisplayName());\n    }\n\n    public static Object adjustTimestampForPartitionTransform(SqlFunctionProperties functionProperties, Type type, Object value)\n    {\n        if (type instanceof TimestampType && functionProperties.isLegacyTimestamp()) {\n            long timestampValue = (long) value;\n            TimestampType timestampType = (TimestampType) type;\n            Instant instant = Instant.ofEpochSecond(timestampType.getEpochSecond(timestampValue),\n                    timestampType.getNanos(timestampValue));\n            LocalDateTime localDateTime = instant\n                    .atZone(ZoneId.of(functionProperties.getTimeZoneKey().getId()))\n                    .toLocalDateTime();\n\n            return timestampType.fromEpochComponents(localDateTime.toEpochSecond(ZoneOffset.UTC), localDateTime.getNano());\n        }\n        return value;\n    }\n","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergPageSink.java#L538-L574","documentation":"IcebergPageSink.getIcebergValue converts a Presto column value into the plain Java value Iceberg uses to key a partition. It supports the scalar Iceberg-writable types (bigint, int/smallint/tinyint, date, boolean, decimal, real, double, varbinary, varchar, timestamp, time); anything else (e.g. maps, arrays, rows, or other complex types used as partition columns) hits the final throw. The library throws this because Iceberg partition values must be simple comparable primitives that can be written into the partition metadata path.","triggerScenarios":"Writing (INSERT/CREATE TABLE AS) into an Iceberg table whose PartitionSpec contains a partition field whose transformed result type is not one of the supported scalar types; getPartitionData calls getIcebergValue for each partition column per row and falls through all instanceof branches.","commonSituations":"Schema evolution or a custom/unsupported partition transform (e.g. a transform producing a complex type) leaves a partition column with a type like array/row/map; a metastore was populated outside Presto with an exotic partition spec; a Presto version lacks support for a newly added Iceberg partition transform.","solutions":["Inspect the table partition spec and remove or replace the unsupported partition column/transform with one of the supported scalar types (bigint, int, boolean, decimal, float, double, string, uuid, binary, date, time, timestamp).","Recreate the table with a supported partition spec (e.g. PARTITIONED BY day(ts) or bucket(...)) instead of the unsupported expression.","Upgrade Presto/iceberg connector to a version that supports the transform in question, since support is added over time.","If the column is not meant to be a partition column, fix the table definition so it is a regular column rather than part of the spec."],"exampleFix":"-- before\nCREATE TABLE t (payload array(bigint), event date)\nWITH (partition_by = ARRAY['payload']);\n-- after\nCREATE TABLE t (payload array(bigint), event date)\nWITH (partition_by = ARRAY['event']);","handlingStrategy":"validation","validationCode":"-- Check partition column types before writing to an Iceberg table\nSELECT column_name, data_type\nFROM information_schema.columns\nWHERE table_schema = 'myschema' AND table_name = 't'\n  AND column_name IN (SELECT ... -- partition columns from SHOW CREATE TABLE output);\n-- Only scalar types (bigint, integer, smallint, tinyint, date, boolean,\n-- decimal, real, double, varbinary, varchar, timestamp, time) are writable partition columns.","typeGuard":null,"tryCatchPattern":"BEGIN\n  INSERT INTO iceberg_table ...;\nEXCEPTION WHEN OTHERS THEN\n  -- surfaces as GENERIC_INTERNAL_ERROR wrapping UnsupportedOperationException\n  -- check message 'Type not supported as partition column: <type>'\n  ROLLBACK;\n  RAISE NOTICE 'Unsupported partition column type; fix partition spec';\nEND;","preventionTips":["Only use supported scalar types as partition columns (avoid array/map/row partition keys).","Use Iceberg transforms (bucket, truncate, year/month/day/hour) on scalar source columns instead of partitioning on complex types.","Run SHOW CREATE TABLE to review the partition spec before writing.","Keep the Presto Iceberg connector up to date so newly supported transforms are available."],"tags":["iceberg","partitioning","unsupported-type","write-path"],"backgroundTag":"unsupported-partition-column-type","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"}