{"record":{"id":"e447c423a5b8023a","repo":"apache/iceberg","slug":"iceberg-does-not-support-spark-geography-edge-algo","errorCode":null,"errorMessage":"Iceberg does not support Spark geography edge algorithm: ","messagePattern":"Iceberg does not support Spark geography edge algorithm: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkTypeToType.java","lineNumber":200,"sourceCode":"      }\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":182,"sourceCodeEnd":205,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkTypeToType.java#L182-L205","documentation":"Iceberg's geography type only supports the SPHERICAL edge-interpolation algorithm. Spark's EdgeInterpolationAlgorithm enum may contain other values (future or non-spherical), and convertAlgorithm rejects anything but SPHERICAL so a new algorithm is not silently dropped.","triggerScenarios":"Converting a Spark schema whose GeographyType carries an edge algorithm other than SPHERICAL (convertAlgorithm is called from atomic() when translating GeographyType).","commonSituations":"Using a Spark/geo build that defines additional edge algorithms while pinned to an older iceberg-spark version; misconfigured geography columns with planar or custom algorithms.","solutions":["Use SPHERICAL edge interpolation in the geography column definition","Upgrade iceberg-spark if a newer version supports the algorithm you need","Drop or change the geography column to a plain geometry/binary if the algorithm cannot be changed"],"exampleFix":"// before: GeographyType(crs, algorithm=PLANAR)\n// after: define geography with spherical edges\nval geo = GeographyType.apply(4326, EdgeInterpolationAlgorithm.SPHERICAL);","handlingStrategy":"validation","validationCode":"if (geoType.algorithm() != null && !\"SPHERICAL\".equalsIgnoreCase(geoType.algorithm().toString())) {\n  throw new IllegalArgumentException(\"Geography must use SPHERICAL edge algorithm\");\n}","typeGuard":"boolean unsupportedAlgorithm(GeographyType t) { return t.algorithm() != null && !\"SPHERICAL\".equalsIgnoreCase(t.algorithm().toString()); }","tryCatchPattern":"try { convert(schema); } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"edge algorithm\")) { /* switch to SPHERICAL */ } throw e; }","preventionTips":["Always define geography columns with spherical edge interpolation","Validate the algorithm field when accepting geo schemas from external producers","Track Spark geo releases for new algorithms before upgrading"],"tags":["spark","geography","edge-algorithm","type-conversion"],"backgroundTag":"unsupported-enum-value","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"}