{"record":{"id":"15565ac856169549","repo":"apache/iceberg","slug":"unknown-position-for-reorder-update-position","errorCode":null,"errorMessage":"Unknown position for reorder: ${update.position()}","messagePattern":"Unknown position for reorder: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java","lineNumber":228,"sourceCode":"      }\n    }\n\n    return pendingUpdate;\n  }\n\n  private static void apply(UpdateSchema pendingUpdate, TableChange.UpdateColumnPosition update) {\n    Preconditions.checkArgument(update.position() != null, \"Invalid position: null\");\n\n    if (update.position() instanceof TableChange.After) {\n      TableChange.After after = (TableChange.After) update.position();\n      String referenceField = peerName(update.fieldNames(), after.column());\n      pendingUpdate.moveAfter(DOT.join(update.fieldNames()), referenceField);\n\n    } else if (update.position() instanceof TableChange.First) {\n      pendingUpdate.moveFirst(DOT.join(update.fieldNames()));\n\n    } else {\n      throw new IllegalArgumentException(\"Unknown position for reorder: \" + update.position());\n    }\n  }\n\n  private static void apply(UpdateSchema pendingUpdate, TableChange.AddColumn add) {\n    Preconditions.checkArgument(\n        add.isNullable(),\n        \"Incompatible change: cannot add required column: %s\",\n        leafName(add.fieldNames()));\n    if (add.defaultValue() != null) {\n      throw new UnsupportedOperationException(\n          String.format(\n              \"Cannot add column %s since setting default values in Spark is currently unsupported\",\n              leafName(add.fieldNames())));\n    }\n\n    Type type = SparkSchemaUtil.convert(add.dataType());\n    pendingUpdate.addColumn(\n        parentName(add.fieldNames()), leafName(add.fieldNames()), type, add.comment());","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java#L210-L246","documentation":"When applying a TableChange.UpdateColumnPosition, Iceberg recognizes only After and First positions for reordering columns. Any other position type (e.g. Spark's default first/last encodings) triggers this IllegalArgumentException because there is no Iceberg move operation for it.","triggerScenarios":"ALTER TABLE ... ALTER COLUMN x AFTER/first-style changes where the UpdateColumnPosition carries a position instance other than TableChange.After or TableChange.First.","commonSituations":"Custom ALTER TABLE reordering logic or an engine integration emitting an unsupported position type; internal mismatches when a Spark release changes its position classes.","solutions":["Only issue AFTER <col> or FIRST column reorders through this path","Normalize the position to TableChange.After or TableChange.First before calling applySchemaChanges","Upgrade Iceberg if a new Spark position type isn't yet mapped"],"exampleFix":"// before\nnew TableChange.UpdateColumnPosition(path, customPosition)\n// after\nnew TableChange.UpdateColumnPosition(path, TableChange.First.getInstance())","handlingStrategy":"type-guard","validationCode":"if (update.position() != null && !(update.position() instanceof TableChange.After) && !(update.position() instanceof TableChange.First)) { throw new IllegalArgumentException(\"Unsupported position: \" + update.position()); }","typeGuard":"boolean isSupportedPosition(TableChange.ColumnPosition p) { return p instanceof TableChange.After || p instanceof TableChange.First; }","tryCatchPattern":"try { Spark3Util.applySchemaChanges(table, changes); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unknown position for reorder\")) { /* normalize to After/First */ } else throw e; }","preventionTips":["Express reorders only as FIRST or AFTER <column>","Convert engine-specific positions to Iceberg's First/After before calling","Avoid hand-building ColumnPosition implementations"],"tags":["spark","column-position","reorder"],"backgroundTag":"invalid-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}