{"record":{"id":"784699e3c1c9964b","repo":"apache/iceberg","slug":"complex-types-currently-not-supported-784699","errorCode":null,"errorMessage":"Complex types currently not supported","messagePattern":"Complex types currently not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java","lineNumber":132,"sourceCode":"          record.set(i, convert(fieldType.asMapType(), row.getJavaMap(i)));\n          break;\n        default:\n          record.set(i, convert(fieldType, row.get(i)));\n      }\n    }\n    return record;\n  }\n\n  public static Object convertToSpark(Type type, Object object) {\n    if (object == null) {\n      return null;\n    }\n\n    switch (type.typeId()) {\n      case STRUCT:\n      case LIST:\n      case MAP:\n        throw new UnsupportedOperationException(\"Complex types currently not supported\");\n      case DATE:\n        return DateTimeUtils.daysToLocalDate((int) object);\n      case TIMESTAMP:\n        Types.TimestampType ts = (Types.TimestampType) type.asPrimitiveType();\n        if (ts.shouldAdjustToUTC()) {\n          return DateTimeUtils.microsToInstant((long) object);\n        } else {\n          return DateTimeUtils.microsToLocalDateTime((long) object);\n        }\n      case BINARY:\n        return ByteBuffers.toByteArray((ByteBuffer) object);\n      case INTEGER:\n      case BOOLEAN:\n      case LONG:\n      case FLOAT:\n      case DOUBLE:\n      case DECIMAL:\n      case STRING:","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java#L114-L150","documentation":"SparkValueConverter.convertToSpark (Iceberg internal value -> Spark value) explicitly rejects complex Iceberg types: STRUCT, LIST and MAP branches throw UnsupportedOperationException('Complex types currently not supported'). At the time this converter was written it only translated primitive values, so nested types are refused instead of silently mis-converted.","triggerScenarios":"Calling convertToSpark with an Iceberg Types.StructType, ListType or MapType (e.g. converting values for nested columns, such as during metadata/partition value conversion on a table with nested partition fields).","commonSituations":"Using older Iceberg versions where nested-column conversion was unimplemented; passing struct/list/map-typed values through APIs that use this converter instead of the full nested conversion paths.","solutions":["Upgrade to an Iceberg release where nested type conversion is supported for your code path","Flatten the schema (extract struct fields / unnest lists) so only primitive columns flow through this converter","Use the DataFrame-based read/write paths instead of the row-object converter for nested data","Cast nested columns to serialized primitives (e.g. to_json -> string) if a legacy pipeline requires it"],"exampleFix":"// before\nObject sparkVal = SparkValueConverter.convertToSpark(structType, record); // STRUCT -> throws\n// after: flatten first\nDataset<Row> flat = df.select(col(\"s.a\"), col(\"s.b\"));","handlingStrategy":"type-guard","validationCode":"static boolean isComplex(Type t) {\n  Type.TypeID id = t.typeId();\n  return id == Type.TypeID.STRUCT || id == Type.TypeID.LIST || id == Type.TypeID.MAP;\n}","typeGuard":"if (!(type instanceof Types.StructType || type instanceof Types.ListType || type instanceof Types.MapType)) { value = SparkValueConverter.convertToSpark(type, object); }","tryCatchPattern":"try {\n  value = SparkValueConverter.convertToSpark(type, object);\n} catch (UnsupportedOperationException e) {\n  if (\"Complex types currently not supported\".equals(e.getMessage())) { /* flatten or serialize the nested value */ }\n  throw e;\n}","preventionTips":["Flatten nested schemas before passing values through primitive-only converters","Upgrade Iceberg if nested conversion support is required on this code path","Use DataFrame read/write APIs for nested data instead of the row-object converter"],"tags":["unsupported-operation","spark","nested-types"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}