prestodb/presto · error · IllegalArgumentException

unsupported type: %s

Error message

unsupported type: %s

What it means

createMetastoreColumnStatistics converts Presto HiveColumnStatistics back into a Metastore ColumnStatisticsObj. It switches on the Hive type's TypeEnum; types not covered by createBooleanStatistics/…/createDecimalStatistics (e.g. LIST, MAP, STRUCT, UNIONTYPE — complex/nested types) reach the default branch and throw IllegalArgumentException. Presto cannot represent column statistics for complex Hive types in the Metastore statistics API.

Source

Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/ThriftMetastoreUtil.java:785

            case LONG:
                return createLongStatistics(columnName, columnType, statistics);
            case FLOAT:
            case DOUBLE:
                return createDoubleStatistics(columnName, columnType, statistics);
            case STRING:
            case VARCHAR:
            case CHAR:
                return createStringStatistics(columnName, columnType, statistics, rowCount);
            case DATE:
                return createDateStatistics(columnName, columnType, statistics);
            case TIMESTAMP:
                return createLongStatistics(columnName, columnType, statistics);
            case BINARY:
                return createBinaryStatistics(columnName, columnType, statistics, rowCount);
            case DECIMAL:
                return createDecimalStatistics(columnName, columnType, statistics);
            default:
                throw new IllegalArgumentException(format("unsupported type: %s", columnType));
        }
    }

    private static ColumnStatisticsObj createBooleanStatistics(String columnName, HiveType columnType, HiveColumnStatistics statistics)
    {
        BooleanColumnStatsData data = new BooleanColumnStatsData();
        statistics.getNullsCount().ifPresent(data::setNumNulls);
        statistics.getBooleanStatistics().ifPresent(booleanStatistics -> {
            booleanStatistics.getFalseCount().ifPresent(data::setNumFalses);
            booleanStatistics.getTrueCount().ifPresent(data::setNumTrues);
        });
        return new ColumnStatisticsObj(columnName, columnType.toString(), booleanStats(data));
    }

    private static ColumnStatisticsObj createLongStatistics(String columnName, HiveType columnType, HiveColumnStatistics statistics)
    {
        LongColumnStatsData data = new LongColumnStatsData();
        statistics.getIntegerStatistics().ifPresent(integerStatistics -> {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Exclude complex-type columns from ANALYZE statistics collection (analyze only primitive columns)
  2. Skip statistics publication for non-primitive columns in the calling code before invoking createMetastoreColumnStatistics
  3. Upgrade Presto if support for the type has since been added

Example fix

// before: publish stats for every column
for (Column col : columns) {
    stats.add(createMetastoreColumnStatistics(col.getName(), col.getType(), ...));
}
// after: only primitive types
if (col.getType().getTypeInfo().getPrimitiveTypeName() == null) continue; // or a primitive-type whitelist
stats.add(createMetastoreColumnStatistics(col.getName(), col.getType(), ...));
Defensive patterns

Strategy: validation

Validate before calling

// only publish stats for primitive Hive types
if (!(columnType.getTypeInfo() instanceof PrimitiveTypeInfo)) {
    log.debug("Skipping stats publication for complex type %s", columnType);
    return;
}

Type guard

boolean isPrimitiveHiveType(HiveType t) {
    return t != null && t.getTypeInfo() instanceof PrimitiveTypeInfo;
}

Try / catch

try {
    obj = ThriftMetastoreUtil.createMetastoreColumnStatistics(name, type, stats, rowCount);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("unsupported type")) {
        log.debug("No metastore stats support for %s", type);
        return null; // omit this column's stats
    }
    throw e;
}

Prevention

When it happens

Trigger: Running ANALYZE (or any code path that publishes column statistics) on a column of a complex/nested type (array, map, struct) whose HiveType falls outside the primitive switch at ThriftMetastoreUtil.java:785.

Common situations: ANALYZE TABLE ... COMPUTE STATISTICS FOR COLUMNS on tables with array/map/struct columns; connectors that blindly publish stats for every column including nested ones.

Related errors


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