apache/iceberg · error · UnsupportedOperationException
Cannot convert Spark geography with mixed SRID to Iceberg
Error message
Cannot convert Spark geography with mixed SRID to Iceberg
What it means
Same as the geometry case: Spark's GeographyType maps to Iceberg's geography type only when it has a single SRID. A Spark geography with mixed SRID cannot be represented in Iceberg, so type conversion throws UnsupportedOperationException.
Source
Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkTypeToType.java:180
} else if (atomic instanceof TimestampNTZType) {
return Types.TimestampType.withoutZone();
} else if (atomic instanceof DecimalType) {
return Types.DecimalType.of(
((DecimalType) atomic).precision(), ((DecimalType) atomic).scale());
} else if (atomic instanceof BinaryType) {
return Types.BinaryType.get();
} else if (atomic instanceof GeometryType) {
GeometryType geometry = (GeometryType) atomic;
if (geometry.isMixedSrid()) {
throw new UnsupportedOperationException(
"Cannot convert Spark geometry with mixed SRID to Iceberg");
}
return Types.GeometryType.of(geometry.crs());
} else if (atomic instanceof GeographyType) {
GeographyType geography = (GeographyType) atomic;
if (geography.isMixedSrid()) {
throw new UnsupportedOperationException(
"Cannot convert Spark geography with mixed SRID to Iceberg");
}
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;View on GitHub (pinned to 86d9c8fc54)
Solutions
- Ensure the geography column has one consistent SRID at the source
- Re-project all geographies to a single SRID before conversion
- Drop the geography column from the schema being converted or store it as binary with explicit handling
Example fix
// before
SparkSchemaUtil.convert(schemaWithMixedSridGeography);
// after: normalize SRID upstream
val fixed = df.withColumn("geo", ST_SetSRID(col("geo"), 4326)); Defensive patterns
Strategy: validation
Validate before calling
org.apache.spark.sql.types.GeographyType g = (GeographyType) dataType;
if (g.isMixedSrid()) throw new IllegalArgumentException("Geography column must have a single SRID before Iceberg conversion"); Type guard
boolean isMixedSridGeography(DataType t) { return t instanceof GeographyType && ((GeographyType) t).isMixedSrid(); } Try / catch
try { convert(schema); } catch (UnsupportedOperationException e) { if (e.getMessage().contains("mixed SRID")) { /* normalize SRID */ } throw e; } Prevention
- Set a single SRID at data production time
- Check isMixedSrid() during schema review before enabling Iceberg on geo datasets
- Document the required CRS for geography columns
When it happens
Trigger: Converting a Spark schema containing a GeographyType column with isMixedSrid() == true to an Iceberg Type (SparkSchemaUtil.convert, Iceberg scans/writes involving that column).
Common situations: Geography columns assembled from sources with differing SRIDs, or geo connectors that leave SRID unset so Spark reports mixed SRID.
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
- Cannot convert Spark geometry with mixed SRID to Iceberg
- Iceberg does not support Spark geography edge algorithm:
- Cannot convert Spark geometry with mixed SRID to Iceberg
- Spark does not support geography edge algorithm:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/f5e9201bdd5898b6.
Report an issue: GitHub.