{"record":{"id":"62f188e68f77348c","repo":"apache/iceberg","slug":"unsupported-type-primitive-62f188","errorCode":null,"errorMessage":"Unsupported type: ${primitive}","messagePattern":"Unsupported type: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetWriters.java","lineNumber":326,"sourceCode":"                        \"Unsupported logical type: \" + primitive.getLogicalTypeAnnotation()));\n      }\n\n      switch (primitive.getPrimitiveTypeName()) {\n        case FIXED_LEN_BYTE_ARRAY:\n        case BINARY:\n          return byteArrays(desc);\n        case BOOLEAN:\n          return ParquetValueWriters.booleans(desc);\n        case INT32:\n          return ints(sType, desc);\n        case INT64:\n          return ParquetValueWriters.longs(desc);\n        case FLOAT:\n          return ParquetValueWriters.floats(desc);\n        case DOUBLE:\n          return ParquetValueWriters.doubles(desc);\n        default:\n          throw new UnsupportedOperationException(\"Unsupported type: \" + primitive);\n      }\n    }\n  }\n\n  private static PrimitiveWriter<?> ints(DataType type, ColumnDescriptor desc) {\n    if (type instanceof ByteType) {\n      return ParquetValueWriters.tinyints(desc);\n    } else if (type instanceof ShortType) {\n      return ParquetValueWriters.shorts(desc);\n    }\n    return ParquetValueWriters.ints(desc);\n  }\n\n  private static PrimitiveWriter<UTF8String> utf8Strings(ColumnDescriptor desc) {\n    return new UTF8StringWriter(desc);\n  }\n\n  private static PrimitiveWriter<UTF8String> uuids(ColumnDescriptor desc) {","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetWriters.java#L308-L344","documentation":"SparkParquetWriters.primitive() maps Spark/Iceberg primitive types to Parquet column writers and falls through to UnsupportedOperationException('Unsupported type: ...') when the physical Parquet type has no writer case, aborting the write task.","triggerScenarios":"Writing a Spark DataFrame to an Iceberg Parquet table with a column whose Parquet physical type falls outside BOOLEAN/INT32/INT64/FLOAT/DOUBLE handled in this switch (e.g. unexpected FIXED_LEN_BYTE_ARRAY or BINARY reached here via an unexpected path).","commonSituations":"Custom write paths or older writer code paths meeting newer types; version mismatch between Spark connector and Iceberg core.","solutions":["Upgrade the Iceberg Spark runtime to match your data types.","Cast unsupported columns to supported types before writing.","Use a write format (Avro/ORC) or writer path that supports the type."],"exampleFix":"// before\ndf.writeTo(\"tbl\") // column with unsupported physical mapping\n// after\ndf.withColumn(\"c\", col(\"c\").cast(\"string\")).writeTo(\"tbl\")","handlingStrategy":"validation","validationCode":"Schema schema = SparkSchemaUtil.convert(df.schema());\nfor (Types.NestedField f : schema.columns()) {\n  // verify types are supported by the Parquet writer for your Iceberg version\n  System.out.println(f.fieldId() + \" -> \" + f.type());\n}","typeGuard":null,"tryCatchPattern":"try {\n  df.writeTo(\"tbl\").append();\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Unsupported type:\")) {\n    // cast offending column before writing\n  }\n}","preventionTips":["Cast exotic columns to supported primitives before writing.","Keep spark-runtime and core versions identical."],"tags":["parquet","spark","unsupported-type","writer"],"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-14T21:17:11.552Z"}