apache/iceberg · error · IcebergAnalysisException
ALTER TABLE has no changes: missing both distribution and…
Error message
ALTER TABLE has no changes: missing both distribution and ordering clauses
What it means
When handling ALTER TABLE ... WRITE (DISTRIBUTED|ORDERED) statements, the AstBuilder requires at least one of a distribution clause or an ordering clause. If the WRITE spec contains neither, it throws this IcebergAnalysisException because the statement would be a no-op.
Solutions
- Add a distribution clause, e.g. `ALTER TABLE t WRITE DISTRIBUTED BY PARTITION`.
- Or add an ordering clause, e.g. `ALTER TABLE t WRITE ORDERED BY col`.
- Or combine both: `ALTER TABLE t WRITE ORDERED BY col` with DISTRIBUTED as needed.
- If no change is intended, drop the ALTER TABLE statement entirely.
Example fix
-- before ALTER TABLE catalog.db.t WRITE -- after ALTER TABLE catalog.db.t WRITE ORDERED BY id
Defensive patterns
Strategy: validation
Validate before calling
-- ensure at least one clause exists before executing -- valid: ALTER TABLE t WRITE DISTRIBUTED BY PARTITION -- valid: ALTER TABLE t WRITE ORDERED BY id -- invalid: ALTER TABLE t WRITE
Prevention
- Never emit a bare `WRITE` clause without DISTRIBUTED or ORDERED.
- In SQL generators, assert the rendered clause list is non-empty.
- Drop no-op ALTER statements early in scripts.
When it happens
Trigger: Running `ALTER TABLE t WRITE` (or a form where both distribution and ordering clauses are absent/empty), leaving the statement without any spec to apply.
Common situations: Incomplete SQL after copy-paste truncation, templated SQL where the clause variables were empty, or misunderstanding that `WRITE` alone changes nothing.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- ALTER TABLE contains multiple distribution clauses
- ALTER TABLE contains multiple ordering clauses
- ALTER TABLE contains multiple distribution clauses
- ALTER TABLE contains multiple distribution clauses
- ALTER TABLE contains multiple distribution clauses
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/774b13453cf4014c.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v4.1/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/parser/extensions/IcebergSqlExtensionsAstBuilder.scala:230
override def visitDropIdentifierFields(ctx: DropIdentifierFieldsContext): DropIdentifierFields =
withOrigin(ctx) {
DropIdentifierFields(
typedVisit[Seq[String]](ctx.multipartIdentifier),
toSeq(ctx.fieldList.fields).map(_.getText))
}
/**
* Create a [[SetWriteDistributionAndOrdering]] for changing the write distribution and ordering.
*/
override def visitSetWriteDistributionAndOrdering(
ctx: SetWriteDistributionAndOrderingContext): SetWriteDistributionAndOrdering = {
val tableName = typedVisit[Seq[String]](ctx.multipartIdentifier)
val (distributionSpec, orderingSpec) = toDistributionAndOrderingSpec(ctx.writeSpec)
if (distributionSpec == null && orderingSpec == null) {
throw new IcebergAnalysisException(
"ALTER TABLE has no changes: missing both distribution and ordering clauses")
}
val distributionMode = if (distributionSpec != null) {
Some(DistributionMode.HASH)
} else if (orderingSpec.UNORDERED != null) {
Some(DistributionMode.NONE)
} else if (orderingSpec.LOCALLY() != null) {
None
} else {
Some(DistributionMode.RANGE)
}
val ordering = if (orderingSpec != null && orderingSpec.order != null) {
toSeq(orderingSpec.order.fields).map(typedVisit[(Term, SortDirection, NullOrder)])
} else {
Seq.empty
}View on GitHub (pinned to 86d9c8fc54)