{"record":{"id":"5fc73f148be6e613","repo":"apache/iceberg","slug":"not-a-supported-type-type-5fc73f","errorCode":null,"errorMessage":"Not a supported type: ${type}","messagePattern":"Not a supported type: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java","lineNumber":90,"sourceCode":"        // if spark.sql.datetime.java8API.enabled is set to true, java.time.LocalDate\n        // for Spark SQL DATE type otherwise java.sql.Date is returned.\n        return DateTimeUtils.anyToDays(object);\n      case TIMESTAMP:\n        return DateTimeUtils.anyToMicros(object);\n      case BINARY:\n        return ByteBuffer.wrap((byte[]) object);\n      case INTEGER:\n        return ((Number) object).intValue();\n      case BOOLEAN:\n      case LONG:\n      case FLOAT:\n      case DOUBLE:\n      case DECIMAL:\n      case STRING:\n      case FIXED:\n        return object;\n      default:\n        throw new UnsupportedOperationException(\"Not a supported type: \" + type);\n    }\n  }\n\n  private static Record convert(Types.StructType struct, Row row) {\n    if (row == null) {\n      return null;\n    }\n\n    Record record = GenericRecord.create(struct);\n    List<Types.NestedField> fields = struct.fields();\n    for (int i = 0; i < fields.size(); i += 1) {\n      Types.NestedField field = fields.get(i);\n\n      Type fieldType = field.type();\n\n      switch (fieldType.typeId()) {\n        case STRUCT:\n          record.set(i, convert(fieldType.asStructType(), row.getStruct(i)));","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java#L72-L108","documentation":"SparkValueConverter.convert (Iceberg type -> value for Spark) has a switch over the Iceberg type's typeId and a default branch that throws UnsupportedOperationException('Not a supported type: ' + type). The library throws this when asked to convert an Iceberg type it does not handle in this direction — only the listed primitive types (and their passthroughs) are supported.","triggerScenarios":"Reading Iceberg data into Spark where a column's Iceberg type falls into the switch's default branch (types not among BOOLEAN..FIXED handled above, e.g. variant or a newer primitive type), reaching SparkValueConverter.convert.","commonSituations":"Tables containing newer Iceberg types (Variant, Unknown) read through an older SparkValueConverter; custom type extensions; version skew between writer and reader Iceberg versions.","solutions":["Upgrade the Iceberg Spark runtime to a version that supports the type shown in the message","Exclude or cast the offending column before reading (schema projection without that column)","If the type should be representable, cast table column to a supported primitive (e.g. string) and rewrite the table","Verify reader and writer use the same Iceberg version to avoid unknown type ids"],"exampleFix":"// before\nDataset<Row> df = spark.read().format(\"iceberg\").load(\"t\"); // includes variant col -> throws\n// after\nDataset<Row> df = spark.read().format(\"iceberg\").load(\"t\").select(\"id\", \"payload\"); // project out unsupported column","handlingStrategy":"validation","validationCode":"static boolean isSupportedPrimitive(Type t) {\n  switch (t.typeId()) {\n    case BOOLEAN: case INTEGER: case LONG: case FLOAT: case DOUBLE:\n    case DECIMAL: case STRING: case FIXED: case DATE: case TIMESTAMP: return true;\n    default: return false;\n  }\n}","typeGuard":"if (isSupportedPrimitive(type)) { Object v = SparkValueConverter.convert(type, object); }","tryCatchPattern":"try {\n  value = SparkValueConverter.convert(type, obj);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Not a supported type\")) { /* project out or upgrade runtime */ }\n  throw e;\n}","preventionTips":["Check table schemas for types your Iceberg version's converter supports before reading","Keep reader and writer Iceberg versions in sync","Project only needed columns so unsupported columns never reach conversion"],"tags":["unsupported-operation","spark","type-conversion"],"backgroundTag":"unsupported-operation","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"}