{"record":{"id":"828c2fe857fa3143","repo":"apache/iceberg","slug":"unknown-position-for-reorder-update-position-828c2f","errorCode":null,"errorMessage":"Unknown position for reorder: <update.position()>","messagePattern":"Unknown position for reorder: <update\\.position\\(\\)>","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java","lineNumber":225,"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":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java#L207-L243","documentation":"When applying a TableChange.UpdateColumnPosition, Spark3Util translates the requested position into a move on the pending UpdateSchema. Only After and First positions are recognized; any other position type (e.g. Default) cannot be expressed and throws IllegalArgumentException.","triggerScenarios":"ALTER TABLE ... ALTER COLUMN ... position DDL translated to a position type other than TableChange.After or TableChange.First reaching Spark3Util.apply(UpdateSchema, UpdateColumnPosition).","commonSituations":"Programmatic DDL translation where a custom or default position was emitted; new position types added in Spark that Iceberg's converter does not handle.","solutions":["Use only TableChange.After or TableChange.First positions when issuing reorder changes","Translate a Default position into an explicit First/After or drop the reordering request","Inspect the change source to confirm the position subtype before calling the utility"],"exampleFix":"// before\nnew TableChange.UpdateColumnPosition(new TableChange.Default(), fieldNames);\n// after\nnew TableChange.UpdateColumnPosition(TableChange.After.of(namesBefore), fieldNames);","handlingStrategy":"validation","validationCode":"if (!(pos instanceof TableChange.After) && !(pos instanceof TableChange.First)) {\n  throw new IllegalArgumentException(\"Only After/First positions are supported, got: \" + pos);\n}","typeGuard":null,"tryCatchPattern":"try {\n  applySchemaChanges(table, changes);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown position for reorder\")) {\n    // re-issue with an explicit After/First position\n  }\n}","preventionTips":["Always construct positions with TableChange.After.of(...) or new TableChange.First()","Avoid TableChange.Default for reorder operations","Test reorder DDL against Iceberg before shipping generators"],"tags":["spark","column-position","invalid-argument-value"],"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"}