{"record":{"id":"36436180c90bbf38","repo":"apache/iceberg","slug":"cannot-drop-partition-field-in-non-iceberg-table-364361","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":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/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/v4.1/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DropPartitionFieldExec.scala#L40-L69","documentation":"DropPartitionFieldExec throws this when ALTER TABLE ... DROP PARTITION FIELD targets a non-Iceberg table. Partition evolution (dropping partition fields via UpdateSpec) is an Iceberg-specific capability; other V2 catalogs do not implement it, so the executor throws UnsupportedOperationException when the table is not a SparkTable wrapping an Iceberg table.","triggerScenarios":"Running `ALTER TABLE ... DROP PARTITION FIELD days(ts)` where the table resolves through a non-Iceberg V2 catalog, so the `case iceberg: SparkTable` branch is not taken.","commonSituations":"Iceberg partition-evolution scripts applied to Delta or Hive tables; wrong catalog binding; test environments where the same table name exists under different catalogs.","solutions":["Qualify the table with the Iceberg catalog so the statement resolves to an Iceberg table","Confirm the partition field exists on the Iceberg table spec (Spark3Util.toIcebergTerm must translate the transform)","For non-Iceberg tables, use that engine's own partition-management commands or migrate to Iceberg"],"exampleFix":"// before\nALTER TABLE my_delta_table DROP PARTITION FIELD days(ts);\n// after\nALTER TABLE iceberg_catalog.db.my_table DROP PARTITION FIELD days(ts);","handlingStrategy":"validation","validationCode":"val loaded = catalog.loadTable(ident)\nrequire(loaded.isInstanceOf[org.apache.iceberg.spark.source.SparkTable], s\"Partition evolution requires Iceberg: $ident\")","typeGuard":"def isIcebergTable(t: org.apache.spark.sql.connector.catalog.Table): Boolean = t.isInstanceOf[org.apache.iceberg.spark.source.SparkTable]","tryCatchPattern":"try { spark.sql(s\"ALTER TABLE $ident DROP PARTITION FIELD days(ts)\") } catch { case e: UnsupportedOperationException if e.getMessage.contains(\"non-Iceberg\") => log.error(s\"Cannot evolve partitions on non-Iceberg table $ident\") }","preventionTips":["List the table's format before running partition-evolution DDL","Qualify DDL with the Iceberg catalog","Audit ETL scripts for Iceberg-specific clauses before reusing them on other formats"],"tags":["spark","spark-extensions","unsupported-operation","partition-evolution"],"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"}