apache/iceberg · error · java.lang.UnsupportedOperationException
Iceberg does not support Spark geography edge algorithm:
Error message
Iceberg does not support Spark geography edge algorithm:
What it means
When converting a Spark GeographyType to Iceberg, convertAlgorithm maps Spark's edge-interpolation algorithm to Iceberg's EdgeAlgorithm. Spark only supports SPHERICAL today, so any other algorithm value hits the default branch and throws this UnsupportedOperationException. The loud failure avoids silently defaulting a new Spark algorithm to the wrong semantics.
Source
Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkTypeToType.java:200
}
return Types.GeographyType.of(geography.crs(), convertAlgorithm(geography.algorithm()));
} else if (atomic instanceof NullType) {
return Types.UnknownType.get();
}
throw new UnsupportedOperationException("Not a supported type: " + atomic.catalogString());
}
// Translates Spark's edge-interpolation algorithm to Iceberg's, mirroring
// TypeToSparkType#convertAlgorithm. Spark supports only the spherical algorithm today; anything
// else is rejected loudly rather than silently defaulting, so a new Spark algorithm surfaces here
// instead of being dropped.
private static EdgeAlgorithm convertAlgorithm(EdgeInterpolationAlgorithm algorithm) {
switch (algorithm.toString().toUpperCase(Locale.ROOT)) {
case "SPHERICAL":
return EdgeAlgorithm.SPHERICAL;
default:
throw new UnsupportedOperationException(
"Iceberg does not support Spark geography edge algorithm: " + algorithm);
}
}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Upgrade iceberg-spark to a version supporting the Spark geography edge algorithm
- Recreate the geography column with the SPHERICAL algorithm (the only supported one)
- Convert the column to geometry (crs only) if edge semantics don't matter for your use
- Check algorithm values with st_ functions/DESCRIBE before writing to Iceberg
Example fix
// before
// geography(geom, 'SOME_NEW_ALGORITHM') -> throws on conversion
// after
df.withColumn("geom", functions.expr("st_geogfromwkb(st_aswkb(geom), true /* spherical */)")); // SPHERICAL Defensive patterns
Strategy: validation
Validate before calling
if (!"SPHERICAL".equalsIgnoreCase(String.valueOf(sparkGeogType.algorithm()))) {
throw new IllegalStateException("Only SPHERICAL geography is supported by Iceberg");
} Type guard
if (dt instanceof org.apache.spark.sql.types.GeographyType g
&& !"SPHERICAL".equalsIgnoreCase(String.valueOf(g.algorithm()))) {
return false; // not convertible until recreated with SPHERICAL
} Try / catch
try {
icebergType = converter.convert(sparkSchema);
} catch (UnsupportedOperationException e) {
if (e.getMessage().contains("edge algorithm")) {
// recreate the column with SPHERICAL or convert to geometry
}
} Prevention
- Always create geography columns with the SPHERICAL algorithm
- Check Spark upgrade notes for new EdgeInterpolationAlgorithm values before adopting
- Pin iceberg-spark versions that match your Spark geography features
- Fall back to geometry (crs-only) when edge semantics are irrelevant
When it happens
Trigger: Schema conversion of a geography column whose EdgeInterpolationAlgorithm is not SPHERICAL (e.g. a new/unknown algorithm introduced by a Spark upgrade or plugin).
Common situations: Running a newer Spark with a new geography algorithm against an older iceberg-spark; corrupted or exotic algorithm values from third-party spatial libraries; copy-pasted DDL with an algorithm string that isn't SPHERICAL.
Related errors
- Iceberg does not support Spark geography edge algorithm:
- Cannot convert Spark geography with mixed SRID to Iceberg
- Cannot process unknown snapshot operation: ${op.toLowerCase(
- Cannot convert Spark geography with mixed SRID to Iceberg
- Unexpected command:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/5b74e0736952f9c3.
Report an issue: GitHub.