{"record":{"id":"daabb7221baf3375","repo":"prestodb/presto","slug":"get-function-metadata-is-not-supported","errorCode":null,"errorMessage":"Get function metadata is not supported","messagePattern":"Get function metadata 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":253,"sourceCode":"\n    @Override\n    public String getCatalogName()\n    {\n        return catalogName;\n    }\n\n    private static class DummyHiveFunction\n            extends HiveFunction\n    {\n        public DummyHiveFunction(Signature signature)\n        {\n            super(signature.getName(), signature, false, true, true, \"\");\n        }\n\n        @Override\n        public FunctionMetadata getFunctionMetadata()\n        {\n            throw new IllegalStateException(\"Get function metadata is not supported\");\n        }\n\n        @Override\n        public SqlFunctionVisibility getVisibility()\n        {\n            return PUBLIC;\n        }\n    }\n\n    private static class EmptyTransactionHandle\n            implements FunctionNamespaceTransactionHandle\n    {\n    }\n\n    private static class FunctionKey\n    {\n        private final QualifiedObjectName name;\n        private final List<TypeSignature> argumentTypes;","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/HiveFunctionNamespaceManager.java#L235-L271","documentation":"This comes from an internal dummy HiveFunction subclass whose getFunctionMetadata() is intentionally unimplemented. These placeholder functions exist solely so listFunctions() can report function names; their metadata is never expected to be requested. Requesting metadata from a dummy function is a programming error and throws IllegalStateException.","triggerScenarios":"Calling getFunctionMetadata() on the dummy HiveFunction instances returned by HiveFunctionNamespaceManager.listFunctions() (created via createDummyHiveFunction).","commonSituations":"Code that iterates listFunctions() output and then queries each function's metadata (visibility, signature, etc.) as it would for real SqlFunction objects; catalog browsers or UIs listing Hive functions and inspecting details.","solutions":["Do not call getFunctionMetadata() on functions from Hive listFunctions(); treat them as name-only placeholders.","Obtain real metadata via getSpecializedFunctionMetadata(FunctionHandle) or resolveFunction first, then query the resolved function.","Filter listFunctions() results to names and use the registry (StaticHiveFunctionRegistry) for actual function details."],"exampleFix":"// before\nfor (var fn : manager.listFunctions()) {\n    var meta = fn.getFunctionMetadata(); // throws for dummy functions\n}\n// after\nfor (var fn : manager.listFunctions()) {\n    var name = fn.getFunctionMetadata().getName(); // or use fn.getSignature() name only\n}","handlingStrategy":"type-guard","validationCode":"// treat listFunctions() results as placeholders: only read name/signature, never metadata","typeGuard":"boolean isHiveDummyFunction(SqlFunction fn) {\n    return fn instanceof HiveFunction && !fn.getSignature().getName().startsWith(\"$\"); // resolve real metadata only for non-placeholder functions\n}","tryCatchPattern":"try {\n    meta = fn.getFunctionMetadata();\n} catch (IllegalStateException e) {\n    meta = manager.getSpecializedFunctionMetadata(handle); // resolve real metadata instead\n}","preventionTips":["Never call getFunctionMetadata() on results of HiveFunctionNamespaceManager.listFunctions().","Use getSpecializedFunctionMetadata(FunctionHandle) for real metadata.","Treat listed functions as name-only entries in UIs/browsers."],"tags":["hive","function-metadata","placeholder-function"],"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"}