{"record":{"id":"58dc6ddf0a3042b1","repo":"apache/iceberg","slug":"not-a-supported-type-58dc6d","errorCode":null,"errorMessage":"Not a supported type: ","messagePattern":"Not a supported type: ","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkTypeToType.java","lineNumber":188,"sourceCode":"    } else if (atomic instanceof GeometryType) {\n      GeometryType geometry = (GeometryType) atomic;\n      if (geometry.isMixedSrid()) {\n        throw new UnsupportedOperationException(\n            \"Cannot convert Spark geometry with mixed SRID to Iceberg\");\n      }\n      return Types.GeometryType.of(geometry.crs());\n    } else if (atomic instanceof GeographyType) {\n      GeographyType geography = (GeographyType) atomic;\n      if (geography.isMixedSrid()) {\n        throw new UnsupportedOperationException(\n            \"Cannot convert Spark geography with mixed SRID to Iceberg\");\n      }\n      return Types.GeographyType.of(geography.crs(), convertAlgorithm(geography.algorithm()));\n    } else if (atomic instanceof NullType) {\n      return Types.UnknownType.get();\n    }\n\n    throw new UnsupportedOperationException(\"Not a supported type: \" + atomic.catalogString());\n  }\n\n  // Translates Spark's edge-interpolation algorithm to Iceberg's, mirroring\n  // TypeToSparkType#convertAlgorithm. Spark supports only the spherical algorithm today; anything\n  // else is rejected loudly rather than silently defaulting, so a new Spark algorithm surfaces here\n  // instead of being dropped.\n  private static EdgeAlgorithm convertAlgorithm(EdgeInterpolationAlgorithm algorithm) {\n    switch (algorithm.toString().toUpperCase(Locale.ROOT)) {\n      case \"SPHERICAL\":\n        return EdgeAlgorithm.SPHERICAL;\n      default:\n        throw new UnsupportedOperationException(\n            \"Iceberg does not support Spark geography edge algorithm: \" + algorithm);\n    }\n  }\n}\n","sourceCodeStart":170,"sourceCodeEnd":205,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkTypeToType.java#L170-L205","documentation":"This is the fallback branch of SparkTypeToType.atomic: a Spark type reached the converter that has no Iceberg mapping (it is not boolean, numeric, decimal, binary, geometry, geography, or null-type). The UnsupportedOperationException reports the unsupported Spark type's catalogString. It prevents silent mis-typing of Spark data in Iceberg schemas.","triggerScenarios":"Converting a schema containing exotic/unsupported Spark atomic types into an Iceberg Type via SparkTypeToType.convert.","commonSituations":"Newer Spark types not yet mapped in the Iceberg version in use; custom Spark types from third-party plugins; using an outdated iceberg-spark build against a newer Spark release introducing new types.","solutions":["Upgrade iceberg-spark to a version whose type converter supports the Spark type","Cast or drop the unsupported column to a supported type (e.g. cast to string/binary) before conversion","Wrap the offending type in a supported equivalent upstream","If the type should be supported, file/port support for it in the converter"],"exampleFix":"// before\nTypes.IcebergType t = new SparkTypeToType().convert(sparkTypeWithUnsupportedType); // throws\n// after\ndf = df.drop(\"unsupportedCol\");\nTypes.IcebergType t = new SparkTypeToType().convert(df.schema());","handlingStrategy":"type-guard","validationCode":"boolean convertible = dt instanceof BooleanType || dt instanceof NumericType\n    || dt instanceof DecimalType || dt instanceof BinaryType\n    || dt instanceof GeometryType || dt instanceof GeographyType || dt instanceof NullType;","typeGuard":"if (!convertible) {\n  throw new IllegalStateException(\"Unsupported Spark type for Iceberg: \" + dt.catalogString());\n}","tryCatchPattern":"try {\n  icebergType = converter.convert(sparkSchema);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Not a supported type:\")) {\n    // cast/drop the offending column and retry\n  }\n}","preventionTips":["Keep iceberg-spark versions in lockstep with your Spark version","Cast exotic types to supported primitives before schema conversion","Drop plugin-defined types before writing Iceberg schemas","Check release notes for newly supported Spark types"],"tags":["spark","type-conversion","schema","unsupported-type"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}