apache/iceberg · error · UnsupportedOperationException
Cannot drop partition field in non-Iceberg table: $table
Error message
Cannot drop partition field in non-Iceberg table: $table
What it means
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.
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
Example fix
// before ALTER TABLE my_delta_table DROP PARTITION FIELD days(ts); // after ALTER TABLE iceberg_catalog.db.my_table DROP PARTITION FIELD days(ts);
Defensive patterns
Strategy: validation
Validate before calling
val loaded = catalog.loadTable(ident) require(loaded.isInstanceOf[org.apache.iceberg.spark.source.SparkTable], s"Partition evolution requires Iceberg: $ident")
Type guard
def isIcebergTable(t: org.apache.spark.sql.connector.catalog.Table): Boolean = t.isInstanceOf[org.apache.iceberg.spark.source.SparkTable]
Try / catch
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") } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Iceberg partition-evolution scripts applied to Delta or Hive tables; wrong catalog binding; test environments where the same table name exists under different catalogs.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot replace partition field in non-Iceberg table: $table
- Cannot drop branch on non-Iceberg table: $table
- Cannot drop identifier fields in non-Iceberg table: $table
- Cannot drop tag on non-Iceberg table: $table
- Cannot set identifier fields in non-Iceberg table: $table
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/36436180c90bbf38.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v4.1/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DropPartitionFieldExec.scala:58
val schema = iceberg.table.schema
transform match {
case IdentityTransform(FieldReference(parts))
if parts.size == 1 && schema.findField(parts.head) == null =>
// the name is not present in the Iceberg schema, so it must be a partition field name, not a column name
iceberg.table
.updateSpec()
.removeField(parts.head)
.commit()
case _ =>
iceberg.table
.updateSpec()
.removeField(Spark3Util.toIcebergTerm(transform))
.commit()
}
case table =>
throw new UnsupportedOperationException(
s"Cannot drop partition field in non-Iceberg table: $table")
}
Nil
}
override def simpleString(maxFields: Int): String = {
s"DropPartitionField ${catalog.name}.${ident.quoted} ${transform.describe}"
}
}
View on GitHub (pinned to 86d9c8fc54)