prestodb/presto · error · IllegalStateException

User defined type is not supported

Error message

User defined type is not supported

What it means

addUserDefinedType() is not supported by the Hive function namespace. The Hive functions namespace is read-only: it exposes Hive's built-in functions and types but does not allow registering user-defined types at runtime. Any attempt throws IllegalStateException immediately.

Source

Thrown at presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/HiveFunctionNamespaceManager.java:178

    public ScalarFunctionImplementation getScalarFunctionImplementation(FunctionHandle functionHandle)
    {
        checkArgument(functionHandle instanceof HiveFunctionHandle);
        HiveFunction function = functions.getUnchecked(FunctionKey.from((HiveFunctionHandle) functionHandle));
        checkState(function instanceof HiveScalarFunction);
        return ((HiveScalarFunction) function).getJavaScalarFunctionImplementation();
    }

    @Override
    public CompletableFuture<SqlFunctionResult> executeFunction(String source, FunctionHandle functionHandle, Page input, List<Integer> channels, TypeManager typeManager)
    {
        throw new IllegalStateException("Execute function is not supported");
    }

    @Override
    public void addUserDefinedType(UserDefinedType userDefinedType)
    {
        throw new IllegalStateException("User defined type is not supported");
    }

    @Override
    public Optional<UserDefinedType> getUserDefinedType(QualifiedObjectName typeName)
    {
        throw new IllegalStateException("User defined type is not supported");
    }

    @Override
    public boolean canResolveFunction()
    {
        return true;
    }

    private HiveFunction initializeFunction(FunctionKey key)
    {
        try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
            QualifiedObjectName name = key.getName();

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Do not register user-defined types against the Hive namespace; register them in a namespace that supports UDTs (e.g. the SQL language function namespace).
  2. Guard the registration call with a capability check before invoking it.
  3. Use Hive's own mechanism (Hive UDF/UDAF/UDTF classes) rather than Presto-side UDT registration for Hive functions.

Example fix

// before
manager.addUserDefinedType(userDefinedType);
// after
if (manager instanceof HiveFunctionNamespaceManager) {
    // skip: UDT registration unsupported for hive namespace
} else {
    manager.addUserDefinedType(userDefinedType);
}
Defensive patterns

Strategy: validation

Validate before calling

if (manager instanceof HiveFunctionNamespaceManager) {
    throw new UnsupportedOperationException("Hive namespace does not support user-defined types");
}

Type guard

boolean supportsUdt(FunctionNamespaceManager m) {
    return !(m instanceof HiveFunctionNamespaceManager);
}

Try / catch

try {
    manager.addUserDefinedType(udt);
} catch (IllegalStateException e) {
    // fall back to a UDT-capable namespace or log and skip
}

Prevention

When it happens

Trigger: Calling addUserDefinedType(UserDefinedType) on the Hive function namespace manager, e.g. from plugin bootstrap code that registers UDTs generically across all namespaces.

Common situations: Plugins that register UDFs/UDTs for multiple function namespaces and assume Hive supports UDT registration; dynamic type registration attempted at runtime.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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