apache/iceberg · error · java.lang.UnsupportedOperationException

Unsupported type: ${primitive}

Error message

Unsupported type: ${primitive}

What it means

The Iceberg Spark Parquet writer throws this when asked to write a physical Parquet primitive type it has no writer mapping for. The exhaustive switch over primitive types covers BOOLEAN/INT32/INT64/FLOAT/DOUBLE/BINARY/FIXED_LEN_BYTE_ARRAY; any other type reaches the default branch and aborts the write.

Source

Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetWriters.java:292

                        "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. Ensure all columns are written with standard Parquet types; avoid INT96 and other legacy types in the schema
  2. Upgrade Iceberg to a version whose writer supports the required primitive type
  3. Inspect the generated Parquet schema (schema() on the write builder) and adjust the Spark data types
  4. If support is genuinely missing, convert the column to a supported type before writing

Example fix

// before: column backed by an unsupported physical type
// after: cast to a supported type before write
df = df.withColumn("ts", col("ts").cast("timestamp")); // standard mapping instead of legacy INT96
Defensive patterns

Strategy: validation

Validate before calling

// Check the physical schema of the write
spark.sessionState.catalog; // or:
table.schema(); // ensure Spark types map to standard Parquet primitives (no INT96/legacy types)

Prevention

When it happens

Trigger: Writing a Spark DataFrame through Iceberg's Parquet writers when a column maps to a physical Parquet primitive type not present in the writer switch — only reachable via an unusual/legacy Parquet type (e.g. INT96) or a custom schema injection, since normal Spark types map to supported physical types.

Common situations: Custom SparkType-to-Parquet mappings in patched builds; forward-ported code where a new Parquet type was added to the enum; writing files intended for systems requiring INT96 timestamps.

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/9bbd9bd1c993304a. Report an issue: GitHub.