{"record":{"id":"61bb6923737e2399","repo":"prestodb/presto","slug":"get-function-is-not-supported","errorCode":null,"errorMessage":"Get function is not supported","messagePattern":"Get function 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":141,"sourceCode":"    public void alterFunction(QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes, AlterRoutineCharacteristics alterRoutineCharacteristics)\n    {\n        throw new IllegalStateException(format(\"Cannot alter function in hive function namespace: %s\", functionName));\n    }\n\n    public void dropFunction(QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes, boolean exists)\n    {\n        throw new IllegalStateException(format(\"Cannot drop function in hive function namespace: %s\", functionName));\n    }\n\n    @Override\n    public Collection<HiveFunction> listFunctions(Optional<String> likePattern, Optional<String> escape)\n    {\n        return getCurrentFunctionNames().stream().map(functionName -> createDummyHiveFunction(functionName)).collect(toImmutableList());\n    }\n\n    public Collection<HiveFunction> getFunctions(Optional<? extends FunctionNamespaceTransactionHandle> transactionHandle, QualifiedObjectName functionName)\n    {\n        throw new IllegalStateException(\"Get function is not supported\");\n    }\n\n    public FunctionHandle getFunctionHandle(Optional<? extends FunctionNamespaceTransactionHandle> transactionHandle, Signature signature)\n    {\n        throw new IllegalStateException(\"Get function handle is not supported\");\n    }\n\n    public FunctionHandle resolveFunction(Optional<? extends FunctionNamespaceTransactionHandle> transactionHandle, QualifiedObjectName functionName, List<TypeSignature> parameterTypes)\n    {\n        return new HiveFunctionHandle(initializeFunction(FunctionKey.of(functionName, parameterTypes)).getSignature());\n    }\n\n    public FunctionMetadata getFunctionMetadata(FunctionHandle functionHandle)\n    {\n        checkArgument(functionHandle instanceof HiveFunctionHandle);\n        HiveFunction function = functions.getUnchecked(FunctionKey.from((HiveFunctionHandle) functionHandle));\n        return function.getFunctionMetadata();\n    }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/HiveFunctionNamespaceManager.java#L123-L159","documentation":"HiveFunctionNamespaceManager.getFunctions() is deliberately unimplemented for transactional lookups; the Hive function namespace only supports listing all functions and resolving functions by name, not fetching a single function by QualifiedObjectName via a transaction handle. The library throws IllegalStateException to signal the caller is using an API surface this namespace does not implement.","triggerScenarios":"Calling getFunctions(Optional<FunctionNamespaceTransactionHandle>, QualifiedObjectName) on the Hive function namespace manager with a specific qualified object name.","commonSituations":"Plugin or connector code written against the generic FunctionNamespaceManager interface that assumes name-based function lookup works the same as in other namespaces (e.g. built-in SQL function namespace); custom integrations or tests invoking transactional lookups against Hive functions.","solutions":["Use listFunctions() instead, which returns dummy HiveFunction instances for every current function name.","Use resolveFunction(transactionHandle, QualifiedObjectName, parameterTypes) to obtain a FunctionHandle for a specific function.","If name-based lookup is required, implement a custom FunctionNamespaceManager for the Hive functions rather than relying on this one."],"exampleFix":"// before\nCollection<? extends SqlFunction> fns = manager.getFunctions(txnHandle, QualifiedObjectName.valueOf(\"hive.default.my_func\"));\n// after\nFunctionHandle handle = manager.resolveFunction(txnHandle, QualifiedObjectName.valueOf(\"hive.default.my_func\"), parameterTypes);","handlingStrategy":"fallback","validationCode":"if (manager instanceof HiveFunctionNamespaceManager) {\n    // name-based getFunctions(txn, name) is unsupported; use listFunctions()/resolveFunction\n}","typeGuard":null,"tryCatchPattern":"try {\n    return manager.getFunctions(txnHandle, name);\n} catch (IllegalStateException e) {\n    return manager.listFunctions().stream()\n        .filter(f -> f.getFunctionMetadata().getName().getObjectName().equals(name.getObjectName()))\n        .collect(toImmutableList());\n}","preventionTips":["Prefer resolveFunction() for locating Hive functions by name.","Do not write code against FunctionNamespaceManager assuming all methods are implemented for every namespace.","Check the namespace type before invoking transactional lookup methods."],"tags":["hive","function-namespace","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"}