{"record":{"id":"fd4f798c68a81c46","repo":"apache/iceberg","slug":"cannot-drop-partition-field-in-non-iceberg-table","errorCode":null,"errorMessage":"Cannot drop partition field in non-Iceberg table: $table","messagePattern":"Cannot drop partition field in non-Iceberg table: \\$table","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DropPartitionFieldExec.scala","lineNumber":58,"sourceCode":"        val schema = iceberg.table.schema\n        transform match {\n          case IdentityTransform(FieldReference(parts))\n              if parts.size == 1 && schema.findField(parts.head) == null =>\n            // the name is not present in the Iceberg schema, so it must be a partition field name, not a column name\n            iceberg.table\n              .updateSpec()\n              .removeField(parts.head)\n              .commit()\n\n          case _ =>\n            iceberg.table\n              .updateSpec()\n              .removeField(Spark3Util.toIcebergTerm(transform))\n              .commit()\n        }\n\n      case table =>\n        throw new UnsupportedOperationException(\n          s\"Cannot drop partition field in non-Iceberg table: $table\")\n    }\n\n    Nil\n  }\n\n  override def simpleString(maxFields: Int): String = {\n    s\"DropPartitionField ${catalog.name}.${ident.quoted} ${transform.describe}\"\n  }\n}\n","sourceCodeStart":40,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DropPartitionFieldExec.scala#L40-L69","documentation":"DropPartitionFieldExec throws this UnsupportedOperationException when a DROP PARTITION FIELD statement targets a non-Iceberg table. Removing a partition field requires Iceberg's updateSpec().removeField() API, which only SparkTable instances wrapping Iceberg tables provide. Any other resolved table falls through to the throwing case.","triggerScenarios":"Running ALTER TABLE ... DROP PARTITION FIELD <transform> against a table that does not match `iceberg: SparkTable` in the plan, e.g. a Hive or Delta table.","commonSituations":"Partition-evolution DDL executed on the wrong table or wrong catalog; sessions where the identifier resolves through a non-Iceberg fallback catalog; mixed-provider namespaces.","solutions":["Check the provider with DESC TABLE EXTENDED and confirm iceberg.","Qualify with the Iceberg catalog: ALTER TABLE iceberg_catalog.db.tbl DROP PARTITION FIELD days(ts).","Register spark.sql.catalog.<name>=org.apache.iceberg.spark.SparkCatalog.","Apply the partition-field drop only to Iceberg tables."],"exampleFix":"-- before\nALTER TABLE db.events DROP PARTITION FIELD days(ts); -- non-Iceberg\n-- after\nALTER TABLE iceberg_catalog.db.events DROP PARTITION FIELD days(ts);","handlingStrategy":"validation","validationCode":"val spec = spark.sql(\"SELECT partition.spec() FROM cat.db.tbl\").collect(); // fails early if not Iceberg","typeGuard":"def supportsPartitionEvolution(t: org.apache.spark.sql.connector.catalog.Table): Boolean = t.isInstanceOf[org.apache.iceberg.spark.source.SparkTable]","tryCatchPattern":"try { spark.sql(\"ALTER TABLE cat.db.tbl DROP PARTITION FIELD days(ts)\") } catch { case e: UnsupportedOperationException if e.getMessage.contains(\"non-Iceberg\") => log.warn(\"partition evolution requires Iceberg\") }","preventionTips":["Qualify partition-evolution DDL with the Iceberg catalog","Confirm provider == 'iceberg' before spec changes","Do not apply partition evolution scripts to mixed-provider table lists"],"tags":["spark","iceberg","unsupported-operation","partitioning"],"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"}