{"record":{"id":"dd7a1c5c2b36db7f","repo":"apache/iceberg","slug":"unknown-position-for-reorder-update-position-dd7a1c","errorCode":null,"errorMessage":"Unknown position for reorder: ${update.position()}","messagePattern":"Unknown position for reorder: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java","lineNumber":242,"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":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java#L224-L260","documentation":"Thrown by the private apply(UpdateSchema, TableChange.UpdateColumnPosition) helper when update.position() is neither TableChange.After nor TableChange.First. There is no mapping for other position types, so column reordering cannot proceed.","triggerScenarios":"Calling ALTER TABLE ... ALTER COLUMN x AFTER/FIRST handling code with a position object that is neither After nor First — typically a custom or future TableChange.Position subtype.","commonSituations":"Custom SQL engines emitting their own Position implementations; forward-compatibility issues after a Spark/Iceberg upgrade adds a new Position subtype.","solutions":["Only construct After or First positions when issuing UpdateColumnPosition changes","Upgrade Iceberg if a new Position type was introduced upstream","Add an explicit branch for the new Position type in local integration code"],"exampleFix":"// before\nTableChange.UpdateColumnPosition upd = TableChange.updateColumnPosition(\n    new String[]{\"col\"}, new MyCustomPosition());\n// after\nTableChange.UpdateColumnPosition upd = TableChange.updateColumnPosition(\n    new String[]{\"col\"}, TableChange.ColumnPosition.after(\"other\"));","handlingStrategy":"validation","validationCode":"if (!(position instanceof TableChange.After) && !(position instanceof TableChange.First)) {\n  throw new IllegalArgumentException(\"Position must be After or First\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  apply(update);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown position for reorder\")) {\n    // convert or drop the position\n  }\n}","preventionTips":["Only use TableChange.first()/after(col) helpers to build positions","Avoid custom Position implementations in integration code","Validate position types before issuing UpdateColumnPosition"],"tags":["spark","schema","column-position"],"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"}