{"record":{"id":"b3797a36e13d4c36","repo":"apache/iceberg","slug":"unsupported-type-b3797a","errorCode":null,"errorMessage":"Unsupported type: ","messagePattern":"Unsupported type: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetWriters.java","lineNumber":312,"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":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetWriters.java#L294-L330","documentation":"SparkParquetWriters.primitive() maps Iceberg primitive types to Parquet physical writers (booleans, ints, longs, floats, doubles, etc.). If an Iceberg type maps to a Parquet primitive not handled by the switch, it throws UnsupportedOperationException with the column descriptor's primitive type. Writer construction for the file fails before any data is written.","triggerScenarios":"Writing an Iceberg table as Parquet from Spark where a column resolves to a Parquet primitive type outside the handled cases of the switch.","commonSituations":"Schema evolution that promoted a column into a type without writer support in this branch; custom write paths supplying non-standard column descriptors; newer Iceberg spec types written with an older Spark integration.","solutions":["Check the table schema and find which column maps to the unsupported primitive type","ALTER the table column to a supported type or cast it before writing (e.g. cast to long/string)","Upgrade Iceberg so the type has writer support in this Spark version","Avoid custom descriptor overrides; let the writer derive Parquet types from the Iceberg schema"],"exampleFix":"// before\ndf.writeTo(\"db.tbl\").append(); // fails on unsupported primitive\n// after\ndf.withColumn(\"col\", functions.col(\"col\").cast(\"long\"))\n  .writeTo(\"db.tbl\").append();","handlingStrategy":"validation","validationCode":"table.schema().columns().forEach(f -> {\n  if (!SUPPORTED_WRITE_TYPE_IDS.contains(f.type().typeId())) {\n    throw new IllegalStateException(\"Column \" + f.name() + \" type \" + f.type() + \" has no Parquet writer\");\n  }\n});","typeGuard":"boolean isParquetWritable(Type type) {\n  switch (type.typeId()) {\n    case BOOLEAN: case INT: case LONG: case FLOAT: case DOUBLE: case DATE:\n    case TIMESTAMP: case STRING: case BINARY: case DECIMAL: case FIXED: case UUID:\n      return true;\n    default: return false;\n  }\n}","tryCatchPattern":"try {\n  df.writeTo(\"db.tbl\").append();\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Unsupported type: \")) {\n    // cast or alter the offending column, then retry\n  } else {\n    throw e;\n  }\n}","preventionTips":["Check Iceberg-to-Parquet type coverage before adding new column types to the table","Avoid custom column-descriptor overrides; derive Parquet types from the Iceberg schema","Upgrade Iceberg together with schema changes that introduce newer spec types"],"tags":["parquet","spark","writer","unsupported-type"],"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"}