prestodb/presto · error · NotSupportedException

Unsupported Hive type: %s

Error message

Unsupported Hive type: %s

What it means

OrcType.toOrcType() converts a Hive/Presto Type into an ORC type tree. Only row/columnar types are handled in this branch; any other type reaches a NotSupportedException("Unsupported Hive type: %s"). Called recursively via itemTypes/keyTypes/valueTypes/fieldOrcTypes when building nested ORC type trees.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/metadata/OrcType.java:260

            return ImmutableList.of(new OrcType(OrcTypeKind.DECIMAL, decimalType.getPrecision(), decimalType.getScale()));
        }
        if (type.getTypeSignature().getBase().equals(ARRAY)) {
            return createOrcArrayType(nextFieldTypeIndex, type.getTypeParameters().get(0));
        }
        if (type.getTypeSignature().getBase().equals(MAP)) {
            return createOrcMapType(nextFieldTypeIndex, type.getTypeParameters().get(0), type.getTypeParameters().get(1));
        }
        if (type.getTypeSignature().getBase().equals(ROW)) {
            List<String> fieldNames = new ArrayList<>();
            for (int i = 0; i < type.getTypeSignature().getParameters().size(); i++) {
                TypeSignatureParameter parameter = type.getTypeSignature().getParameters().get(i);
                fieldNames.add(parameter.getNamedTypeSignature().getName().orElse("field" + i));
            }
            List<Type> fieldTypes = type.getTypeParameters();

            return createOrcRowType(nextFieldTypeIndex, fieldNames, fieldTypes);
        }
        throw new NotSupportedException(format("Unsupported Hive type: %s", type));
    }

    private static List<OrcType> createOrcArrayType(int nextFieldTypeIndex, Type itemType)
    {
        nextFieldTypeIndex++;
        List<OrcType> itemTypes = toOrcType(nextFieldTypeIndex, itemType);

        List<OrcType> orcTypes = new ArrayList<>();
        orcTypes.add(new OrcType(OrcTypeKind.LIST, ImmutableList.of(nextFieldTypeIndex), ImmutableList.of("item")));
        orcTypes.addAll(itemTypes);
        return orcTypes;
    }

    private static List<OrcType> createOrcMapType(int nextFieldTypeIndex, Type keyType, Type valueType)
    {
        nextFieldTypeIndex++;
        List<OrcType> keyTypes = toOrcType(nextFieldTypeIndex, keyType);
        List<OrcType> valueTypes = toOrcType(nextFieldTypeIndex + keyTypes.size(), valueType);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Coerce the column to a supported Hive type (e.g. CAST to VARCHAR/ROW/etc.) before writing
  2. Upgrade Presto so toOrcType handles the type
  3. Identify the offending type from the message and exclude/cast it in the schema

Example fix

// before
CREATE TABLE t WITH (format='ORC') AS SELECT custom_type_col FROM src; -- NotSupportedException
// after
CREATE TABLE t WITH (format='ORC') AS SELECT CAST(custom_type_col AS VARCHAR) AS custom_type_col FROM src;
Defensive patterns

Strategy: validation

Validate before calling

// Before writing, verify each Hive column type is ORC-mappable
private static final Set<String> SUPPORTED_ROOTS = Set.of("array", "map", "row");
String base = type.getBaseType().toLowerCase(Locale.ROOT);
if (!SUPPORTED_ROOTS.contains(base)) {
    throw new IllegalArgumentException("Coerce or drop column of type " + type + " before ORC write");
}

Type guard

boolean isOrcMappable(Type type) {
    String base = type.getBaseType().toLowerCase(Locale.ROOT);
    return Set.of("array", "map", "row").contains(base);
}

Try / catch

try {
    orcType = OrcType.toOrcType(tableName, hiveTypes);
} catch (NotSupportedException e) {
    throw new IllegalStateException("Column type not writable to ORC: " + e.getMessage() + "; CAST it to a supported type", e);
}

Prevention

When it happens

Trigger: Writing ORC output for a Hive/Presto type that is not array/map/row/struct (e.g. a parameterized or custom type falling through the switch), including nested inside containers via itemTypes/keyTypes/valueTypes/fieldOrcTypes.

Common situations: CTAS or INSERT into ORC tables with exotic column types (e.g. custom parametric types, unknown functions-of-types); connector plugins exposing non-mappable types; Presto version gaps for newer Hive types.

Related errors


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