{"record":{"id":"85de932e618d09a1","repo":"prestodb/presto","slug":"iceberg-incompatible-column-type","errorCode":"ICEBERG_INCOMPATIBLE_COLUMN_TYPE","errorMessage":"Failed to set column type: ","messagePattern":"Failed to set column type: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java","lineNumber":2878,"sourceCode":"    private boolean viewExists(ConnectorSession session, ConnectorTableMetadata viewMetadata)\n    {\n        return getViewMetadata(session, viewMetadata.getTable()).isPresent();\n    }\n\n    @Override\n    public void setColumnType(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle, com.facebook.presto.common.type.Type type)\n    {\n        IcebergTableHandle table = (IcebergTableHandle) tableHandle;\n        IcebergColumnHandle column = (IcebergColumnHandle) columnHandle;\n\n        Table icebergTable = getIcebergTable(session, table.getSchemaTableName());\n        try {\n            icebergTable.updateSchema()\n                    .updateColumn(column.getName(), toIcebergType(type).asPrimitiveType())\n                    .commit();\n        }\n        catch (RuntimeException e) {\n            throw new PrestoException(ICEBERG_INCOMPATIBLE_COLUMN_TYPE, \"Failed to set column type: \" + firstNonNull(e.getMessage(), e), e);\n        }\n    }\n\n    protected void openCreateTableTransaction(SchemaTableName tableName, Transaction transaction)\n    {\n        transactionContext.registerTransaction(tableName, transaction);\n    }\n\n    /**\n     * Check and ensure that the specified statement can only run in a transaction with autocommit context set to true.\n     * */\n    protected void shouldRunInAutoCommitTransaction(String statement)\n    {\n        if (!transactionContext.isAutoCommitContext()) {\n            throw new PrestoException(ICEBERG_TRANSACTION_CONFLICT_ERROR, statement + \" cannot be called within a transaction (use autocommit mode) in Iceberg connector.\");\n        }\n    }\n}","sourceCodeStart":2860,"sourceCodeEnd":2896,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java#L2860-L2896","documentation":"Wraps any RuntimeException from the Iceberg schema-update commit when a column's type is changed (ALTER TABLE ... ALTER COLUMN TYPE). The underlying Iceberg updateColumn rejected the type change, typically because the new type is not a promotable primitive type for the existing column.","triggerScenarios":"Calling IcebergAbstractMetadata.setColumnType (ALTER TABLE ... SET COLUMN TYPE) where icebergTable.updateSchema().updateColumn(...).commit() throws, e.g. widening int to varchar, changing a nested field type, or conflicting concurrent schema updates.","commonSituations":"Attempting unsupported type promotions (int->varchar, timestamp<->timestamptz, decimal precision narrowing), altering columns inside nested structs/maps, or concurrent schema evolution conflicts.","solutions":["Only use Iceberg-supported type promotions (e.g. int->long, float->double, decimal precision widening)","Read the wrapped cause (the last exception in the chain) for the exact schema-update failure reason","Add a new column, backfill with UPDATE, and drop the old column instead of an in-place type change","Retry if the failure was a concurrent-commit conflict (ConcurrentModificationException from Iceberg)"],"exampleFix":"// before\nALTER TABLE t ALTER COLUMN c SET DATA TYPE VARCHAR; -- int -> varchar not promotable\n// after\nALTER TABLE t ADD COLUMN c_str VARCHAR;\nUPDATE t SET c_str = CAST(c AS VARCHAR);\nALTER TABLE t DROP COLUMN c;","handlingStrategy":"try-catch","validationCode":"// only attempt Iceberg-promotable widenings\nSet<String> promotable = Set.of(\"integer->bigint\",\"float->double\",\"decimal->decimal(precision,wider scale)\");\nif (!isPromotable(currentType, newType)) throw new IllegalArgumentException(\"Unsupported Iceberg type change: \" + currentType + \" -> \" + newType);","typeGuard":null,"tryCatchPattern":"try { ALTER ... } catch (PrestoException e) { if (\"ICEBERG_INCOMPATIBLE_COLUMN_TYPE\".equals(e.getErrorCode().getName())) { /* inspect e.getCause() for the schema-commit failure; fall back to add/backfill/drop */ } else throw e; }","preventionTips":["Only perform Iceberg-supported promotions (int->bigint, float->double, decimal widening)","Never change primitive families in place; use add-column/backfill/drop-column","Avoid concurrent schema edits on the same table","Check nested-field type rules before altering struct/map children"],"tags":["iceberg","schema-evolution","column-type","incompatible-type"],"backgroundTag":"incompatible-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"}