apache/iceberg · error · UnsupportedOperationException

Unsupported base type for decimal:

Error message

Unsupported base type for decimal: 

What it means

When writing decimals to Parquet, FlinkParquetWriters' LogicalTypeWriterBuilder.visit(DecimalLogicalTypeAnnotation) writes decimals as either BINARY or FIXED_LEN_BYTE_ARRAY physical base types; any other primitive (INT32/INT64 bases used by some producers) hits the default branch and throws UnsupportedOperationException 'Unsupported base type for decimal: <type>'.

Source

Thrown at flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetWriters.java:253

      return Optional.of(strings(desc));
    }

    @Override
    public Optional<ParquetValueWriter<?>> visit(DecimalLogicalTypeAnnotation decimal) {
      ParquetValueWriter<DecimalData> writer;
      switch (desc.getPrimitiveType().getPrimitiveTypeName()) {
        case INT32:
          writer = decimalAsInteger(desc, decimal.getPrecision(), decimal.getScale());
          break;
        case INT64:
          writer = decimalAsLong(desc, decimal.getPrecision(), decimal.getScale());
          break;
        case BINARY:
        case FIXED_LEN_BYTE_ARRAY:
          writer = decimalAsFixed(desc, decimal.getPrecision(), decimal.getScale());
          break;
        default:
          throw new UnsupportedOperationException(
              "Unsupported base type for decimal: "
                  + desc.getPrimitiveType().getPrimitiveTypeName());
      }
      return Optional.of(writer);
    }

    @Override
    public Optional<ParquetValueWriter<?>> visit(DateLogicalTypeAnnotation dates) {
      return Optional.of(ints(flinkType, desc));
    }

    @Override
    public Optional<ParquetValueWriter<?>> visit(TimeLogicalTypeAnnotation times) {
      Preconditions.checkArgument(
          LogicalTypeAnnotation.TimeUnit.MICROS.equals(times.getUnit()),
          "Cannot write time in %s, only MICROS is supported",
          times.getUnit());
      return Optional.of(timeMicros(desc));

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Rewrite the data so decimals are stored as BINARY or FIXED_LEN_BYTE_ARRAY (Iceberg's canonical encoding)
  2. Check which tool wrote the Parquet files and use its reader instead
  3. Convert the column to a supported decimal representation

Example fix

// before: decimal stored as INT32 base (external writer)
// after: rewrite via Iceberg spark rewrite or copy to BINARY-based decimal
Defensive patterns

Strategy: validation

Validate before calling

org.apache.parquet.schema.PrimitiveTypeName base = desc.getPrimitiveType().getPrimitiveTypeName();
Preconditions.checkArgument(
    base == BINARY || base == FIXED_LEN_BYTE_ARRAY,
    "Decimal must use BINARY/FIXED_LEN_BYTE_ARRAY base, found: " + base);

Try / catch

try {
  Optional<ParquetValueWriter<?>> w = visitor.visit(decimalAnnotation);
} catch (UnsupportedOperationException e) {
  throw new WriteException("Cannot write decimal with this base type", e);
}

Prevention

When it happens

Trigger: Visiting a decimal logical annotation whose ColumnDescriptor primitive is not BINARY or FIXED_LEN_BYTE_ARRAY, e.g. decimals stored as INT32/INT64/FLBA-variant by external writers.

Common situations: Reading paths where the writer builder is handed descriptors from files written by other systems that store decimals on integer bases, or misconfigured schema evolution.

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/3e96d9fc62889156. Report an issue: GitHub.