{"record":{"id":"db686f9a6381109a","repo":"apache/iceberg","slug":"cannot-drop-identifier-fields-in-non-iceberg-table-db686f","errorCode":null,"errorMessage":"Cannot drop identifier fields in non-Iceberg table: $table","messagePattern":"Cannot drop identifier fields in non-Iceberg table: \\$table","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DropIdentifierFieldsExec.scala","lineNumber":58,"sourceCode":"\n        for (name <- fields) {\n          Preconditions.checkArgument(\n            schema.findField(name) != null,\n            \"Cannot complete drop identifier fields operation: field %s not found\",\n            name)\n          Preconditions.checkArgument(\n            identifierFieldNames.contains(name),\n            \"Cannot complete drop identifier fields operation: %s is not an identifier field\",\n            name)\n          identifierFieldNames.remove(name)\n        }\n\n        iceberg.table\n          .updateSchema()\n          .setIdentifierFields(identifierFieldNames)\n          .commit();\n      case table =>\n        throw new UnsupportedOperationException(\n          s\"Cannot drop identifier fields in non-Iceberg table: $table\")\n    }\n\n    Nil\n  }\n\n  override def simpleString(maxFields: Int): String = {\n    s\"DropIdentifierFields ${catalog.name}.${ident.quoted} (${fields.quoted})\";\n  }\n}\n","sourceCodeStart":40,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DropIdentifierFieldsExec.scala#L40-L69","documentation":"This UnsupportedOperationException is thrown by Spark's DROP IDENTIFIER FIELDS execution when the target table is not an Iceberg table. Identifier fields are part of the Iceberg table schema spec, so only Iceberg tables support setting/dropping them; the non-Iceberg match arm throws.","triggerScenarios":"Running 'ALTER TABLE ... DROP IDENTIFIER FIELDS ...' against a table that resolves to a non-Iceberg Spark table.","commonSituations":"Using Iceberg-specific schema DDL on Delta/Parquet/Hive tables; catalog alias resolving to a non-Iceberg provider.","solutions":["Verify the table is Iceberg-managed","Fully qualify the table with the Iceberg catalog name","Fix the spark.sql.catalog registration so the table resolves to Iceberg","If identifiers aren't needed, skip the operation on non-Iceberg tables"],"exampleFix":"// before\nALTER TABLE plain_table DROP IDENTIFIER FIELDS id;\n// after\nALTER TABLE iceberg_catalog.db.plain_table DROP IDENTIFIER FIELDS id;","handlingStrategy":"validation","validationCode":"val icebergTable = Spark3Util.loadIcebergTable(spark, fullTableName)\nrequire(icebergTable != null, s\"$fullTableName is not an Iceberg table\")","typeGuard":"def isIcebergTable(spark: SparkSession, name: String): Boolean =\n  scala.util.Try(Spark3Util.loadIcebergTable(spark, name)).map(_ != null).getOrElse(false)","tryCatchPattern":null,"preventionTips":["Use identifier-field DDL only on Iceberg tables","Qualify the table with its Iceberg catalog","Keep scripts per-provider rather than reusing Iceberg DDL elsewhere"],"tags":["spark","iceberg","unsupported-operation","identifier-fields"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}