apache/iceberg · error
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 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.
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.
Example fix
-- before ALTER TABLE db.events DROP PARTITION FIELD days(ts); -- non-Iceberg -- after ALTER TABLE iceberg_catalog.db.events DROP PARTITION FIELD days(ts);
Defensive patterns
Strategy: validation
Validate before calling
val spec = spark.sql("SELECT partition.spec() FROM cat.db.tbl").collect(); // fails early if not Iceberg Type guard
def supportsPartitionEvolution(t: org.apache.spark.sql.connector.catalog.Table): Boolean = t.isInstanceOf[org.apache.iceberg.spark.source.SparkTable]
Try / catch
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") } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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 add partition field to non-Iceberg table: $table
- Cannot replace partition field in non-Iceberg table: $table
- Cannot add partition field to non-Iceberg table: $table
- Cannot convert predicate to SQL
- Cannot convert term to SQL
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/fd4f798c68a81c46.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v3.5/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)