apache/iceberg · error · UnsupportedOperationException

Unsupported base type for decimal: " + primitive.getPrimitiv

Error message

Unsupported base type for decimal: " + primitive.getPrimitiveTypeName()

What it means

Inside VectorizedArrowReader's logical-type visitor, decimal columns are only supported over INT32, INT64, and fixed-size binary physical bases. When a decimal's backing physical type is anything else, visit() throws this UnsupportedOperationException because there is no decimal read path for that base type.

Source

Thrown at arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorizedArrowReader.java:525

      switch (primitive.getPrimitiveTypeName()) {
        case BINARY:
        case FIXED_LEN_BYTE_ARRAY:
          ((FixedSizeBinaryVector) vector).allocateNew(batchSize);
          return Optional.of(
              new LogicalTypeVisitorResult(
                  vector, ReadType.FIXED_LENGTH_DECIMAL, primitive.getTypeLength()));
        case INT64:
          ((BigIntVector) vector).allocateNew(batchSize);
          return Optional.of(
              new LogicalTypeVisitorResult(
                  vector, ReadType.LONG_BACKED_DECIMAL, (int) BigIntVector.TYPE_WIDTH));
        case INT32:
          ((IntVector) vector).allocateNew(batchSize);
          return Optional.of(
              new LogicalTypeVisitorResult(
                  vector, ReadType.INT_BACKED_DECIMAL, (int) IntVector.TYPE_WIDTH));
        default:
          throw new UnsupportedOperationException(
              "Unsupported base type for decimal: " + primitive.getPrimitiveTypeName());
      }
    }

    @Override
    public Optional<LogicalTypeVisitorResult> visit(
        LogicalTypeAnnotation.DateLogicalTypeAnnotation dateLogicalType) {
      FieldVector vector = arrowField.createVector(rootAlloc);
      ((DateDayVector) vector).allocateNew(batchSize);
      return Optional.of(
          new LogicalTypeVisitorResult(vector, ReadType.INT, (int) IntVector.TYPE_WIDTH));
    }

    @Override
    public Optional<LogicalTypeVisitorResult> visit(
        LogicalTypeAnnotation.TimeLogicalTypeAnnotation timeLogicalType) {
      FieldVector vector = arrowField.createVector(rootAlloc);
      ((TimeMicroVector) vector).allocateNew(batchSize);

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Rewrite the data so decimals use INT32/INT64/FIXED_LEN_BYTE_ARRAY physical types (standard Iceberg writes do this)
  2. Disable vectorized reads to use the generic decimal path
  3. Upgrade Iceberg for newer supported decimal base types

Example fix

// before
// BINARY-backed decimal + vectorized reads -> throws
// after
table.updateProperties().set(TableProperties.PARQUET_VECTORIZATION_ENABLED, "false");
Defensive patterns

Strategy: fallback

Validate before calling

if (decimalType.getLogicalTypeAnnotation() instanceof DecimalLogicalTypeAnnotation dec) {
  PrimitiveTypeName base = primitive.getPrimitiveTypeName();
  boolean ok = base == PrimitiveTypeName.INT32 || base == PrimitiveTypeName.INT64
      || base == PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY;
  if (!ok) { /* use generic reader */ }
}

Type guard

boolean decimalBaseSupported(PrimitiveType p) {
  return p.getPrimitiveTypeName() == PrimitiveTypeName.INT32
      || p.getPrimitiveTypeName() == PrimitiveTypeName.INT64
      || p.getPrimitiveTypeName() == PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY;
}

Try / catch

try {
  return vectorizedDecimalReader();
} catch (UnsupportedOperationException e) {
  return genericDecimalReader();
}

Prevention

When it happens

Trigger: Vectorized read of a Parquet decimal column whose primitive base type is not INT32/INT64/FixedSizeBinary (e.g. BINARY-backed or FLOAT-backed decimal), reaching the default branch of the decimal visit method.

Common situations: Parquet files produced by third-party writers storing decimals in nonstandard physical layouts; enabling vectorization for tables with legacy decimal encodings.

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/5e52375337e78068. Report an issue: GitHub.