{"record":{"id":"392453ec071d188d","repo":"apache/iceberg","slug":"cannot-drop-partition-field-in-non-iceberg-table-392453","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.2/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.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DropPartitionFieldExec.scala#L40-L69","documentation":"This UnsupportedOperationException is thrown by Spark's DROP PARTITION FIELD execution when the target table is not an Iceberg table. Partition field (partition spec evolution) changes are Iceberg-only; the non-Iceberg table case falls through to the default match and throws.","triggerScenarios":"Running 'ALTER TABLE ... DROP PARTITION FIELD <transform>' where the table resolves to a non-Iceberg Spark table.","commonSituations":"Migrating DDL scripts written for Iceberg to tables in other formats; missing or wrong catalog qualification; catalog plugin misconfiguration.","solutions":["Confirm the table is an Iceberg table","Qualify the table name with the Iceberg catalog in the DDL","Check spark.sql.catalog.<name> points to org.apache.iceberg.spark.SparkCatalog","Rewrite the statement to the native provider's partitioning API if the table is not Iceberg"],"exampleFix":"// before\nALTER TABLE other_table DROP PARTITION FIELD years(ts);\n// after\nALTER TABLE iceberg_catalog.db.other_table DROP PARTITION FIELD years(ts);","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":["Confirm provider=iceberg via DESCRIBE TABLE EXTENDED before partition evolution","Qualify with the Iceberg catalog in DDL scripts","Separate Iceberg-specific DDL from other engines' scripts"],"tags":["spark","iceberg","unsupported-operation","partition-spec"],"backgroundTag":"unsupported-operation","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"}