apache/iceberg · error · UnsupportedOperationException
Cannot convert Spark geometry with mixed SRID to Iceberg
Error message
Cannot convert Spark geometry with mixed SRID to Iceberg
What it means
Spark's GeometryType is converted to Iceberg's geometry type during schema translation, but Iceberg requires a single SRID (coordinate reference system). A Spark geometry whose SRID is mixed (contains multiple/unknown SRIDs) cannot be represented in Iceberg, so conversion throws UnsupportedOperationException.
Source
Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkTypeToType.java:173
} else if (atomic instanceof DateType) {
return Types.DateType.get();
} else if (atomic instanceof TimestampType) {
return Types.TimestampType.withZone();
} 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, mirroringView on GitHub (pinned to 86d9c8fc54)
Solutions
- Fix the source data so the geometry column has a single, well-defined SRID
- Cast/re-project geometries to a common SRID before handing the schema to Iceberg
- Use a different (non-Iceberg) storage format for mixed-SRID geometry data
Example fix
// before: geometry column with mixed SRIDs converted directly
Types.StructType converted = SparkSchemaUtil.convert(sparkSchema);
// after: re-project to a single SRID first
df = df.withColumn("geom", ST_Transform(col("geom"), 4326)); Defensive patterns
Strategy: validation
Validate before calling
org.apache.spark.sql.types.GeometryType g = (GeometryType) dataType;
if (g.isMixedSrid()) throw new IllegalArgumentException("Geometry column must have a single SRID before Iceberg conversion"); Type guard
boolean isMixedSridGeometry(DataType t) { return t instanceof GeometryType && ((GeometryType) t).isMixedSrid(); } Try / catch
try { convert(schema); } catch (UnsupportedOperationException e) { if (e.getMessage().contains("mixed SRID")) { /* re-project geometry */ } throw e; } Prevention
- Normalize SRIDs upstream (ST_Transform / ST_SetSRID) before ingestion
- Validate geo columns' SRID in ingestion pipelines
- Keep geo library and Spark geo support versions aligned
When it happens
Trigger: Converting a Spark schema containing a GeometryType column with isMixedSrid() == true to an Iceberg Type — e.g. via SparkSchemaUtil.convert or when reading/writing a Spark dataframe with such geometry columns against Iceberg.
Common situations: Geometry data loaded without a declared CRS/SRID, unioned geometries with differing SRIDs, or Spark geo types produced by connectors that leave SRID unspecified.
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 geometry with mixed SRID to Iceberg
- Cannot convert Spark geography with mixed SRID to Iceberg
- 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/0450893c3c129881.
Report an issue: GitHub.