prestodb/presto · error · IllegalArgumentException
Unexpected decimal type: ${decimalType}
Error message
Unexpected decimal type: ${decimalType} What it means
convertPartitionValueToDouble converts a partition key's constant value to a double for statistics estimation; when the value's type is a DecimalType that is neither short (<= 64-bit) nor long (<= 128-bit) decimal, it throws IllegalArgumentException 'Unexpected decimal type'. In practice this means the decimal type is out of the supported precision range or the value/type pairing is inconsistent.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/statistics/MetastoreHiveStatisticsProvider.java:667
{
if (type.equals(BIGINT) || type.equals(INTEGER) || type.equals(SMALLINT) || type.equals(TINYINT)) {
return (Long) value;
}
if (type.equals(DOUBLE)) {
return (Double) value;
}
if (type.equals(REAL)) {
return intBitsToFloat(((Long) value).intValue());
}
if (type instanceof DecimalType) {
DecimalType decimalType = (DecimalType) type;
if (isShortDecimal(decimalType)) {
return parseDouble(Decimals.toString((Long) value, decimalType.getScale()));
}
if (isLongDecimal(decimalType)) {
return parseDouble(Decimals.toString((Slice) value, decimalType.getScale()));
}
throw new IllegalArgumentException("Unexpected decimal type: " + decimalType);
}
if (type.equals(DATE)) {
return (Long) value;
}
throw new IllegalArgumentException("Unexpected type: " + type);
}
@VisibleForTesting
static ColumnStatistics createDataColumnStatistics(String column, Type type, double rowsCount, Collection<PartitionStatistics> partitionStatistics)
{
List<HiveColumnStatistics> columnStatistics = partitionStatistics.stream()
.map(PartitionStatistics::getColumnStatistics)
.map(statistics -> statistics.get(column))
.filter(Objects::nonNull)
.collect(toImmutableList());
if (columnStatistics.isEmpty()) {
return ColumnStatistics.empty();View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the partition column's decimal precision/scale in the metastore and correct it to a valid DECIMAL(p,s)
- Recreate the partition/table with a supported DECIMAL declaration
- Check the Hive-to-Presto type mapping for decimals and align versions
- Change the partition column to a supported type or exclude it from stats estimation
Example fix
// before (corrupted type) DECIMAL(0,0) // precision out of supported range // after DECIMAL(10,2)
Defensive patterns
Strategy: validation
Validate before calling
// validate decimal declaration before use
DecimalType d = (DecimalType) type;
boolean supported = d.getPrecision() >= 1
&& (d.getPrecision() <= Decimals.MAX_SHORT_PRECISION || d.getPrecision() <= Decimals.MAX_PRECISION);
if (!supported) throw new IllegalArgumentException("Unsupported decimal: " + d); Try / catch
try {
stats = provider.getTableStatistics(...);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unexpected decimal type")) {
// fix partition column DECIMAL(p,s) in the metastore, then re-run ANALYZE
} else throw e;
} Prevention
- Declare partition decimals with valid precision/scale (e.g. DECIMAL(10,2))
- Verify Hive decimal type mapping matches the Presto version in use
- Audit metastore schemas after migrations for malformed decimal types
- Re-create affected partitions after correcting the type
When it happens
Trigger: Estimating stats over a partition column whose value conversion hits a decimal type where isShortDecimal and isLongDecimal are both false — i.e. a malformed/oversized decimal type reaching the stats path.
Common situations: Partition column declared with an unsupported or corrupted decimal precision in the metastore; type-mapping mismatch between Hive decimal and Presto decimal conversions; value stored with a type that no longer matches the schema.
Related errors
- Unexpected decimal type:
- INVALID_ANALYZE_PROPERTY
- Number of values not set for orc file. Set session property
- HIVE_CORRUPTED_COLUMN_STATISTICS
- Unexpected type: ${type}
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/d8c48198349e0c19.
Report an issue: GitHub.