{"record":{"id":"093826dc9b01f930","repo":"prestodb/presto","slug":"generic-internal-error-093826","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Invalid partition type ","messagePattern":"Invalid partition type ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java","lineNumber":961,"sourceCode":"            }\n            if (isShortDecimal(type) || isLongDecimal(type)) {\n                DecimalType decimalType = (DecimalType) type;\n                BigDecimal decimal = new BigDecimal(valueString);\n                decimal = decimal.setScale(decimalType.getScale(), BigDecimal.ROUND_UNNECESSARY);\n                checkArgument(decimal.precision() <= decimalType.getPrecision());\n                BigInteger unscaledValue = decimal.unscaledValue();\n                return isShortDecimal(type) ? unscaledValue.longValue() : Decimals.encodeUnscaledValue(unscaledValue);\n            }\n        }\n        catch (IllegalArgumentException e) {\n            throw new PrestoException(ICEBERG_INVALID_PARTITION_VALUE, format(\n                    \"Invalid partition value '%s' for %s partition key: %s\",\n                    valueString,\n                    type.getDisplayName(),\n                    name));\n        }\n        // Iceberg tables don't partition by non-primitive-type columns.\n        throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Invalid partition type \" + type.toString());\n    }\n\n    public static Domain createDomainFromIcebergPartitionValue(\n            Object value,\n            org.apache.iceberg.types.Type icebergType,\n            Type prestoType)\n    {\n        if (value == null) {\n            return onlyNull(prestoType);\n        }\n\n        switch (icebergType.typeId()) {\n            case INTEGER:\n            case DATE:\n                return singleValue(prestoType, ((Integer) value).longValue());\n            case LONG:\n            case BOOLEAN:\n                return singleValue(prestoType, value);","sourceCodeStart":943,"sourceCodeEnd":979,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java#L943-L979","documentation":"deserializeIcebergValue handles only Presto primitive types (boolean, integer, bigint, real, double, timestamp, time, date, varchar, varbinary, decimal). If the partition key's Presto type is not one of these, it falls through and throws PrestoException(GENERIC_INTERNAL_ERROR, \"Invalid partition type ...\"), because Iceberg tables are not expected to partition on non-primitive-type columns. Hitting it means the connector encountered a partition key type it believes cannot exist.","triggerScenarios":"Reading Iceberg partitions where a partition field maps to a non-primitive Presto type (e.g. map, array, struct, row, or any type not matched in the if-chain in deserializeIcebergValue). Typically only occurs with corrupted/hand-edited metadata or an engine that wrote an unsupported partition spec.","commonSituations":"External writers partitioning on complex columns contrary to the Iceberg spec assumption; connector type mapping mismatches after schema evolution; hand-modified partition specs in metadata JSON.","solutions":["Inspect the table's Iceberg partition spec to identify the non-primitive partition field and rewrite the table so partition keys are primitive columns","Check for schema/partition-spec edits by other engines; revert to a spec with only primitive partition keys","If this appears with a valid spec, it is a connector type-mapping bug — report it with the partition spec and schema to the Presto maintainers","As a workaround, drop/replace the offending partition field in the spec (Iceberg partition fields are advisory for reads; repartition the data)"],"exampleFix":"// before: partition spec on a struct column\nPartitionSpec spec = PartitionSpec.builderFor(schema).identity(\"nested_struct_col\").build();\n// after: partition on a primitive column extracted from the data\nPartitionSpec spec = PartitionSpec.builderFor(schema).identity(\"event_date\").build();","handlingStrategy":"validation","validationCode":"// Ensure all partition fields map to primitive types before querying\njava.util.Set<String> PRIMITIVES = java.util.Set.of(\"boolean\",\"integer\",\"long\",\"float\",\"double\",\"date\",\"time\",\"timestamp\",\"string\",\"uuid\",\"decimal\",\"fixed\",\"binary\");\nboolean hasOnlyPrimitivePartitionFields(org.apache.iceberg.Table table) {\n    return table.spec().fields().stream()\n        .allMatch(f -> PRIMITIVES.contains(f.transform().getResultType(\n            table.schema().findType(f.sourceId())).typeId().toString().toLowerCase()));\n}","typeGuard":"boolean isPrimitivePartitionType(org.apache.iceberg.types.Type t) {\n    switch (t.typeId()) {\n        case BOOLEAN: case INTEGER: case LONG: case FLOAT: case DOUBLE:\n        case DATE: case TIME: case TIMESTAMP: case STRING: case UUID:\n        case DECIMAL: case FIXED: case BINARY:\n            return true;\n        default:\n            return false;\n    }\n}","tryCatchPattern":"try {\n    session.execute(query);\n} catch (QueryFailedException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid partition type\")) {\n        // inspect/fix the partition spec; this is not retryable\n    } else throw e;\n}","preventionTips":["Partition Iceberg tables only on primitive columns (per the Iceberg spec)","Never hand-edit partition spec JSON in metadata files","Re-check partition specs after table migrations between engines","Keep the Presto Iceberg connector and writer engine versions compatible"],"tags":["iceberg","partitioning","internal-error","type-mapping"],"backgroundTag":"unsupported-partition-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"}