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

  1. Verify the partition column's decimal precision/scale in the metastore and correct it to a valid DECIMAL(p,s)
  2. Recreate the partition/table with a supported DECIMAL declaration
  3. Check the Hive-to-Presto type mapping for decimals and align versions
  4. 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

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


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/d8c48198349e0c19. Report an issue: GitHub.