apache/iceberg · error · java.lang.UnsupportedOperationException
Spark does not support geography edge algorithm:
Error message
Spark does not support geography edge algorithm:
What it means
Iceberg geography columns carry an edge interpolation algorithm, but Spark's geography support only recognizes the spherical algorithm. convertAlgorithm throws when a geography column specifies any other edge algorithm.
Source
Thrown at spark/v4.2/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)
Solutions
- Rewrite the geography column with edge algorithm spherical (or use geometry instead of geography)
- Skip/exclude the geography column from Spark queries
- Upgrade to an Iceberg/Spark version supporting the algorithm
Example fix
// before
Types.GeographyType.get("srid", EdgeAlgorithm.VINCENTY);
// after
Types.GeographyType.get("srid", EdgeAlgorithm.SPHERICAL); Defensive patterns
Strategy: validation
Validate before calling
table.schema().columns().stream()
.filter(c -> c.type() instanceof Types.GeographyType)
.map(c -> (Types.GeographyType) c.type())
.forEach(g -> Preconditions.checkArgument(
g.algorithm() == null || g.algorithm().name().equals("SPHERICAL"),
"Non-spherical geography not supported in Spark: %s", g)); Try / catch
try { df = spark.read().load("iceberg_geo_table"); }
catch (UnsupportedOperationException e) {
if (e.getMessage().contains("edge algorithm")) { /* rewrite column or exclude */ }
else throw e;
} Prevention
- Use spherical edges for geography columns
- Prefer geometry when non-spherical edges are needed
- Keep geo schemas within Spark-supported algorithms
When it happens
Trigger: Reading a table whose schema has a geography column with an edge algorithm other than spherical (e.g. vincenty or a future spec algorithm) through the Spark type converter.
Common situations: Tables written by geospatial-enabled engines using non-spherical edges, later queried in Spark; spec evolution introducing new algorithms ahead of Spark support.
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 convert Spark geography with mixed SRID to Iceberg
- Iceberg does not support Spark geography edge algorithm:
- Cannot convert Spark geography with mixed SRID to Iceberg
- Not a supported type: type
- Spark does not support time fields
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/fdc4f56c2c4d0a24.
Report an issue: GitHub.