prestodb/presto · error · IllegalArgumentException

Unknown type

Error message

Unknown type 

What it means

getTypeName maps thrift ParquetType enum values to parquet-mr PrimitiveTypeName values; an unmapped enum value falls through to the default case and throws IllegalArgumentException. This means the file's schema declares a physical type this reader doesn't recognize — usually a newer Parquet type written by a newer library version.

Source

Thrown at presto-parquet/src/main/java/com/facebook/presto/parquet/cache/MetadataReader.java:495

        switch (type) {
            case BYTE_ARRAY:
                return PrimitiveTypeName.BINARY;
            case INT64:
                return PrimitiveTypeName.INT64;
            case INT32:
                return PrimitiveTypeName.INT32;
            case BOOLEAN:
                return PrimitiveTypeName.BOOLEAN;
            case FLOAT:
                return PrimitiveTypeName.FLOAT;
            case DOUBLE:
                return PrimitiveTypeName.DOUBLE;
            case INT96:
                return PrimitiveTypeName.INT96;
            case FIXED_LEN_BYTE_ARRAY:
                return PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY;
            default:
                throw new IllegalArgumentException("Unknown type " + type);
        }
    }

    private static OriginalType getOriginalType(ConvertedType type)
    {
        switch (type) {
            case UTF8:
                return OriginalType.UTF8;
            case MAP:
                return OriginalType.MAP;
            case MAP_KEY_VALUE:
                return OriginalType.MAP_KEY_VALUE;
            case LIST:
                return OriginalType.LIST;
            case ENUM:
                return OriginalType.ENUM;
            case DECIMAL:
                return OriginalType.DECIMAL;

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Upgrade Presto/presto-parquet to a version supporting the newer parquet-format types
  2. Re-write the file with only widely-supported physical types (e.g. convert exotic types to primitives)
  3. Inspect the file's schema with parquet-tools to identify the offending column type
  4. If corruption is suspected, validate the file and re-generate it

Example fix

// before: default: throw new IllegalArgumentException("Unknown type " + type);
// after
default:
    LOG.warn("Unknown parquet type %s, falling back to BINARY", type);
    return PrimitiveTypeName.BINARY;
Defensive patterns

Strategy: validation

Validate before calling

// probe schema before full read
Set<PrimitiveTypeName> used = readSchema(dataSource).stream()
    .map(TypeName::of)
    .collect(toSet());
Set<PrimitiveTypeName> supported = EnumSet.allOf(PrimitiveTypeName.class); // match reader version
if (!supported.containsAll(used)) {
    throw new UnsupportedSchemaException(used);
}

Type guard

// narrow unknown types before use
boolean isSupportedType(ParquetType t) {
    return Arrays.stream(PrimitiveTypeName.values())
        .anyMatch(p -> p.name().equals(t.name()));
}

Try / catch

try {
    readParquetMetadata(dataSource);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Unknown type ")) {
        // unsupported physical type: request library upgrade / rewrite file
        throw new UnsupportedParquetTypeException(e.getMessage(), e);
    } else throw e;
}

Prevention

When it happens

Trigger: readParquetSchema → primitiveBuilder calls getTypeName with a ConvertedType/ParquetType enum constant not present in the switch (e.g. a type added in a newer parquet-format spec than the reader supports).

Common situations: Reading files written by newer Parquet/Impala/Spark writers with types unknown to an older Presto; corrupted thrift schema bytes producing invalid enum values; schema manually edited.

Related errors


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