apache/iceberg · error · UnsupportedOperationException
Replacing a view is not supported by catalog:
Error message
Replacing a view is not supported by catalog:
What it means
replaceView in SparkSessionCatalog throws UnsupportedOperationException when neither the delegate view catalog nor the session catalog supports view replacement. This is the view counterpart of CREATE OR REPLACE and is only proxied when the underlying catalog implements ViewCatalog.
Solutions
- Use DROP VIEW then CREATE VIEW against a view-capable catalog, or add a view-capable delegate
- Point the operation at a catalog that implements ViewCatalog (e.g. Iceberg REST catalog with view support)
- Rewrite the SQL to use ALTER VIEW ... AS SELECT where the engine supports it
Example fix
// before
spark.sql("CREATE OR REPLACE VIEW iceberg.db.v AS SELECT ..."); // unsupported here
// after
spark.sql("DROP VIEW IF EXISTS spark_catalog.db.v");
spark.sql("CREATE VIEW spark_catalog.db.v AS SELECT ..."); Defensive patterns
Strategy: fallback
Type guard
boolean supportsViews(Catalog c) { return c instanceof ViewCatalog; } Try / catch
try {
catalog.replaceView(...);
} catch (UnsupportedOperationException e) {
// DROP VIEW + CREATE VIEW fallback
} Prevention
- Prefer DROP/CREATE over CREATE OR REPLACE VIEW when view support is uncertain
- Standardize view management on a single view-capable catalog
When it happens
Trigger: Executing CREATE OR REPLACE VIEW on a catalog with no ViewCatalog delegate; the view exists only in a non-view-capable catalog so no branch handles the replace.
Common situations: CI pipelines replacing views against a catalog that never supported views; misconfigured catalog name causing resolution against the wrong, view-less catalog; pre-3.3 Spark sessions lacking view APIs.
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
- Altering a view is not supported by catalog:
- Altering a view is not supported by catalog
- Altering a view is not supported by catalog
- Creating a view is not supported by catalog:
- Creating a view is not supported by catalog
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/fe223f0691fbc7f8.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java:543
String[] columnAliases,
String[] columnComments,
Map<String, String> properties)
throws NoSuchNamespaceException, NoSuchViewException {
if (asViewCatalog instanceof SupportsReplaceView) {
return ((SupportsReplaceView) asViewCatalog)
.replaceView(
ident,
sql,
currentCatalog,
currentNamespace,
schema,
queryColumnNames,
columnAliases,
columnComments,
properties);
}
throw new UnsupportedOperationException(
"Replacing a view is not supported by catalog: " + catalogName);
}
@Override
public View alterView(Identifier ident, ViewChange... changes)
throws NoSuchViewException, IllegalArgumentException {
if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {
return asViewCatalog.alterView(ident, changes);
} else if (isViewCatalog()) {
return getSessionCatalog().alterView(ident, changes);
}
throw new UnsupportedOperationException(
"Altering a view is not supported by catalog: " + catalogName);
}
@Override
public boolean dropView(Identifier ident) {View on GitHub (pinned to 86d9c8fc54)