{"record":{"id":"904ee2839502d11c","repo":"prestodb/presto","slug":"user-defined-type-is-not-supported","errorCode":null,"errorMessage":"User defined type is not supported","messagePattern":"User defined type is not supported","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/HiveFunctionNamespaceManager.java","lineNumber":178,"sourceCode":"\n    public ScalarFunctionImplementation getScalarFunctionImplementation(FunctionHandle functionHandle)\n    {\n        checkArgument(functionHandle instanceof HiveFunctionHandle);\n        HiveFunction function = functions.getUnchecked(FunctionKey.from((HiveFunctionHandle) functionHandle));\n        checkState(function instanceof HiveScalarFunction);\n        return ((HiveScalarFunction) function).getJavaScalarFunctionImplementation();\n    }\n\n    @Override\n    public CompletableFuture<SqlFunctionResult> executeFunction(String source, FunctionHandle functionHandle, Page input, List<Integer> channels, TypeManager typeManager)\n    {\n        throw new IllegalStateException(\"Execute function is not supported\");\n    }\n\n    @Override\n    public void addUserDefinedType(UserDefinedType userDefinedType)\n    {\n        throw new IllegalStateException(\"User defined type is not supported\");\n    }\n\n    @Override\n    public Optional<UserDefinedType> getUserDefinedType(QualifiedObjectName typeName)\n    {\n        throw new IllegalStateException(\"User defined type is not supported\");\n    }\n\n    @Override\n    public boolean canResolveFunction()\n    {\n        return true;\n    }\n\n    private HiveFunction initializeFunction(FunctionKey key)\n    {\n        try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {\n            QualifiedObjectName name = key.getName();","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/HiveFunctionNamespaceManager.java#L160-L196","documentation":"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.","triggerScenarios":"Calling addUserDefinedType(UserDefinedType) on the Hive function namespace manager, e.g. from plugin bootstrap code that registers UDTs generically across all namespaces.","commonSituations":"Plugins that register UDFs/UDTs for multiple function namespaces and assume Hive supports UDT registration; dynamic type registration attempted at runtime.","solutions":["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).","Guard the registration call with a capability check before invoking it.","Use Hive's own mechanism (Hive UDF/UDAF/UDTF classes) rather than Presto-side UDT registration for Hive functions."],"exampleFix":"// before\nmanager.addUserDefinedType(userDefinedType);\n// after\nif (manager instanceof HiveFunctionNamespaceManager) {\n    // skip: UDT registration unsupported for hive namespace\n} else {\n    manager.addUserDefinedType(userDefinedType);\n}","handlingStrategy":"validation","validationCode":"if (manager instanceof HiveFunctionNamespaceManager) {\n    throw new UnsupportedOperationException(\"Hive namespace does not support user-defined types\");\n}","typeGuard":"boolean supportsUdt(FunctionNamespaceManager m) {\n    return !(m instanceof HiveFunctionNamespaceManager);\n}","tryCatchPattern":"try {\n    manager.addUserDefinedType(udt);\n} catch (IllegalStateException e) {\n    // fall back to a UDT-capable namespace or log and skip\n}","preventionTips":["Register UDTs only in namespaces that support them.","Check manager type before UDT registration in multi-namespace plugins.","Keep Hive-side types defined via Hive UDF classes rather than Presto UDTs."],"tags":["hive","user-defined-type","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}