{"record":{"id":"ae0347d029348433","repo":"apache/iceberg","slug":"not-a-supported-type-ae0347","errorCode":null,"errorMessage":"Not a supported type: ","messagePattern":"Not a supported type: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/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.1/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java#L72-L108","documentation":"SparkValueConverter.convert maps Iceberg primitive types to Spark-compatible values and throws UnsupportedOperationException for any type it does not explicitly handle. It is a deliberate capability guard: the converter only supports a fixed set of primitive types (the visible cases pass through DOUBLE/DECIMAL/STRING/FIXED values unchanged), so encountering an unhandled typeId means the requested conversion is outside the converter's supported surface.","triggerScenarios":"Calling the public convert method with an Iceberg type whose typeId falls into the switch's default branch - e.g. a TIMESTAMP, TIMESTAMP_NS, DATE, UUID, or BINARY column passed through this conversion path.","commonSituations":"Reading or writing tables containing timestamp, binary, or uuid columns via Spark code paths that use SparkValueConverter for row conversion; using newer Iceberg type kinds (timestamp-nanoseconds) with an older Spark integration module.","solutions":["Check the Iceberg type of the offending column and confirm the converter version handles it; upgrade to an Iceberg/Spark version where the type is supported","Convert unsupported types (e.g. timestamps, binary) manually before calling the converter","If the type should be supported, upgrade the iceberg-spark module or file an issue to extend the switch"],"exampleFix":"// before\nObject sparkVal = SparkValueConverter.convert(structType, row); // throws for TIMESTAMP field\n// after\nObject raw = row.get(tsFieldPos);\nObject sparkVal = raw instanceof Long\n    ? DateTimeUtils.microsToTimestamp((Long) raw)\n    : SparkValueConverter.convert(structType, row);","handlingStrategy":"type-guard","validationCode":"Set<Type.TypeID> supported = Set.of(Type.TypeID.BOOLEAN, Type.TypeID.INTEGER, Type.TypeID.LONG,\n    Type.TypeID.FLOAT, Type.TypeID.DOUBLE, Type.TypeID.DECIMAL, Type.TypeID.STRING, Type.TypeID.FIXED);\nif (!supported.contains(type.typeId())) {\n  throw new IllegalArgumentException(\"Column type not supported by converter: \" + type);\n}","typeGuard":"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:\n      return true;\n    default:\n      return false;\n  }\n}","tryCatchPattern":"try {\n  value = SparkValueConverter.convert(structType, row);\n} catch (UnsupportedOperationException e) {\n  LOG.warn(\"Unsupported type conversion, passing raw value through\", e);\n  value = row.getField(fieldName);\n}","preventionTips":["Project scans to supported primitive columns before converting rows","Check the Iceberg type's typeId before invoking the converter","Keep iceberg-spark modules on the same version as iceberg-core","Add unit tests covering every column type in your schema"],"tags":["spark","unsupported-type","iceberg","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-14T11:17:12.474Z"}