apache/iceberg · error · UnsupportedOperationException
Unsupported base type for decimal:
Error message
Unsupported base type for decimal:
What it means
SparkParquetReaders.primitive() reads DECIMAL logical types from Parquet. Decimals must be physically stored as INT32, INT64, or FIXED_LEN_BYTE_ARRAY. If the underlying Parquet primitive is anything else (e.g. BINARY or FLOAT), the reader throws UnsupportedOperationException because it cannot decode a decimal from that storage type.
Source
Thrown at spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetReaders.java:257
case DATE:
case INT_64:
return new UnboxedReader<>(desc);
case TIMESTAMP_MICROS:
case TIMESTAMP_MILLIS:
return ParquetValueReaders.timestamps(desc);
case DECIMAL:
DecimalLogicalTypeAnnotation decimal =
(DecimalLogicalTypeAnnotation) primitive.getLogicalTypeAnnotation();
switch (primitive.getPrimitiveTypeName()) {
case BINARY:
case FIXED_LEN_BYTE_ARRAY:
return new BinaryDecimalReader(desc, decimal.getScale());
case INT64:
return new LongDecimalReader(desc, decimal.getPrecision(), decimal.getScale());
case INT32:
return new IntegerDecimalReader(desc, decimal.getPrecision(), decimal.getScale());
default:
throw new UnsupportedOperationException(
"Unsupported base type for decimal: " + primitive.getPrimitiveTypeName());
}
case BSON:
return new ParquetValueReaders.ByteArrayReader(desc);
default:
throw new UnsupportedOperationException(
"Unsupported logical type: " + primitive.getOriginalType());
}
}
switch (primitive.getPrimitiveTypeName()) {
case FIXED_LEN_BYTE_ARRAY:
case BINARY:
if (expected != null && expected.typeId() == TypeID.UUID) {
return new UUIDReader(desc);
}
return new ParquetValueReaders.ByteArrayReader(desc);
case INT32:View on GitHub (pinned to 86d9c8fc54)
Solutions
- Inspect the Parquet file schema (parquet-tools / parquet cat --schema) and confirm the decimal column's physical type
- Rewrite the offending data files with a standard producer (Spark/Iceberg) so decimals use INT32/INT64/FIXED_LEN_BYTE_ARRAY
- Re-annotate or re-encode the column as BINARY if the data is not actually decimal, and update the table schema accordingly
- Upgrade Iceberg if support for additional decimal encodings has been added in newer versions
Defensive patterns
Strategy: validation
Validate before calling
MessageType schema = parquetFileReader.getFooter().getFileMetaData().getSchema();
for (ColumnDescriptor col : schema.getColumns()) {
if (col.getPrimitiveTypeName() == PrimitiveTypeName.BINARY
&& schema.containsPath(col.getPath()) /* check annotation */ ) {
// verify decimal columns use INT32/INT64/FIXED_LEN_BYTE_ARRAY before reading
}
} Try / catch
try {
spark.read().format("iceberg").load("db.tbl");
} catch (UnsupportedOperationException e) {
if (e.getMessage().startsWith("Unsupported base type for decimal")) {
// rewrite the offending files with a standard Parquet producer
} else {
throw e;
}
} Prevention
- Run parquet-tools schema checks on externally produced files before registering them in Iceberg
- Only write decimals with standard encodings (INT32/INT64/FIXED_LEN_BYTE_ARRAY)
- Avoid third-party tools that re-annotate columns without re-encoding physical data
When it happens
Trigger: Reading a Parquet file whose column is annotated as DECIMAL logical type but whose physical type is not INT32/INT64/FIXED_LEN_BYTE_ARRAY — encountered while doing a Spark read of an Iceberg Parquet table.
Common situations: Files written by non-standard Parquet producers that store decimals in BINARY without the expected FLBA layout; corrupted schema metadata; third-party tools that re-annotated columns as DECIMAL without re-encoding the physical data.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Unsupported base type for decimal:
- Unsupported base type for decimal: ${primitive.getPrimitiveT
- Unsupported base type for decimal: ${primitive.getPrimitiveT
- Unsupported type: ${primitive}
- Unsupported logical type:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/1792506cc5f31eb7.
Report an issue: GitHub.