apache/iceberg · error · UnsupportedOperationException

Unsupported type: {primitive}

Error message

Unsupported type: {primitive}

What it means

SparkParquetWriters.primitive maps Spark/ Iceberg primitive types to Parquet writers; only known physical types (INT32/INT64/FLOAT/DOUBLE/etc.) are handled. The default branch throws UnsupportedOperationException when a column's Parquet primitive type has no matching writer.

Source

Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetWriters.java:328

                        "Unsupported logical type: " + primitive.getLogicalTypeAnnotation()));
      }

      switch (primitive.getPrimitiveTypeName()) {
        case FIXED_LEN_BYTE_ARRAY:
        case BINARY:
          return byteArrays(desc);
        case BOOLEAN:
          return ParquetValueWriters.booleans(desc);
        case INT32:
          return ints(sType, desc);
        case INT64:
          return ParquetValueWriters.longs(desc);
        case FLOAT:
          return ParquetValueWriters.floats(desc);
        case DOUBLE:
          return ParquetValueWriters.doubles(desc);
        default:
          throw new UnsupportedOperationException("Unsupported type: " + primitive);
      }
    }
  }

  private static PrimitiveWriter<?> ints(DataType type, ColumnDescriptor desc) {
    if (type instanceof ByteType) {
      return ParquetValueWriters.tinyints(desc);
    } else if (type instanceof ShortType) {
      return ParquetValueWriters.shorts(desc);
    }
    return ParquetValueWriters.ints(desc);
  }

  private static PrimitiveWriter<UTF8String> utf8Strings(ColumnDescriptor desc) {
    return new UTF8StringWriter(desc);
  }

  private static PrimitiveWriter<UTF8String> uuids(ColumnDescriptor desc) {

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Upgrade the iceberg-spark module to match your table spec version so new types have writers.
  2. Exclude or retype unsupported columns (e.g. cast to string) before writing.
  3. Inspect the generated Parquet schema (write.parquet) to confirm which column maps to the unsupported primitive.
Defensive patterns

Strategy: validation

Validate before calling

// before writing, confirm every Iceberg type in the schema has a Parquet writer mapping in your Iceberg version
schema.columns().forEach(c -> Preconditions.checkArgument(
    !c.type().equals(Types.UUID.get()), // example: type absent in old writers
    "Type %s may not be writable with this iceberg-spark version", c.type()));

Prevention

When it happens

Trigger: Writing data where a column descriptor's Parquet primitive type is not one of the types handled in the switch — usually from a schema mapping that produced an exotic physical type (e.g. certain fixed-byte or binary cases unhandled by this writer path).

Common situations: Schema evolution producing unexpected physical layouts; using an older Iceberg Spark writer with newer Iceberg types (e.g. uuid, variant) not mapped in this version.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/5c24e9b0f58983cb. Report an issue: GitHub.