apache/iceberg · error · UnsupportedOperationException
Spark does not support geography edge algorithm:
Error message
Spark does not support geography edge algorithm:
What it means
Spark's geometry support recognizes only the spherical edge interpolation algorithm; convertAlgorithm maps Iceberg edge algorithms to Spark's and throws UnsupportedOperationException for any other (e.g. planar/edge algorithms from the geo spec). The comment notes PruneColumnsWithoutReordering compares algorithms across type systems.
Solutions
- Recreate or rewrite the geography column with the SPHERICAL algorithm
- Prune the geography column from the Spark read projection
- Upgrade Spark/Iceberg if support for the algorithm is added later
Defensive patterns
Strategy: validation
Validate before calling
Types.GeographyType geo = (Types.GeographyType) t; boolean ok = geo.algorithm() == EdgeAlgorithm.SPHERICAL;
Type guard
boolean isSphericalGeography(Type t) { return t instanceof Types.GeographyType g && g.algorithm() == EdgeAlgorithm.SPHERICAL; } Try / catch
try { convertAlgorithm(alg); } catch (UnsupportedOperationException e) { LOG.error("Unsupported edge algorithm {}", alg, e); throw e; } Prevention
- Use SPHERICAL edges for geography columns shared with Spark
- Document engine-specific geo limitations for shared tables
- Prune geography columns when edges are incompatible
When it happens
Trigger: Converting a geography-typed column whose edge algorithm is not SPHERICAL — tables created by engines/spec writers using non-spherical geography edges, read or pruned via Spark.
Common situations: Geo tables produced by non-Spark engines using planar edges; schema evolution changing the geography edge algorithm; cross-engine catalog access.
Related errors
- Unsupported manifest content type
- Already closed files for partition:
- 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/429963b99a010955.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/TypeToSparkType.java:192
// IllegalArgumentException).
return GeometryType$.MODULE$.apply(geometry.crs());
}
private DataType geographyType(Types.GeographyType geography) {
// The spec requires a geography CRS to be geographic; Spark recognizes only OGC:CRS84, so any
// other CRS throws SparkIllegalArgumentException (an IllegalArgumentException).
return GeographyType$.MODULE$.apply(geography.crs(), convertAlgorithm(geography.algorithm()));
}
// Translates Iceberg's edge-interpolation algorithm to Spark's. Spark supports only the spherical
// algorithm (the Iceberg default); every other algorithm is rejected with a clear error. Shared
// with PruneColumnsWithoutReordering, which compares algorithms across the two type systems.
static EdgeInterpolationAlgorithm convertAlgorithm(EdgeAlgorithm algorithm) {
switch (algorithm) {
case SPHERICAL:
return SPARK_SPHERICAL;
default:
throw new UnsupportedOperationException(
"Spark does not support geography edge algorithm: " + algorithm);
}
}
private Metadata fieldMetadata(int fieldId) {
if (MetadataColumns.metadataFieldIds().contains(fieldId)) {
return new MetadataBuilder().putBoolean(METADATA_COL_ATTR_KEY, true).build();
}
return Metadata.empty();
}
}
View on GitHub (pinned to 86d9c8fc54)