{"record":{"id":"8808e8cac5893f9a","repo":"prestodb/presto","slug":"generic-user-error-8808e8","errorCode":"GENERIC_USER_ERROR","errorMessage":"SHOW CREATE FUNCTION is only supported for SQL functions","messagePattern":"SHOW CREATE FUNCTION is only supported for SQL functions","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java","lineNumber":666,"sourceCode":"            QualifiedObjectName functionName = metadata.getFunctionAndTypeManager().getFunctionAndTypeResolver().qualifyObjectName(node.getName());\n            Collection<? extends SqlFunction> functions = metadata.getFunctionAndTypeManager().getFunctions(session, functionName);\n            if (node.getParameterTypes().isPresent()) {\n                List<TypeSignature> parameterTypes = node.getParameterTypes().get().stream()\n                        .map(TypeSignature::parseTypeSignature)\n                        .collect(toImmutableList());\n                functions = functions.stream()\n                        .filter(function -> function.getSignature().getArgumentTypes().equals(parameterTypes))\n                        .collect(toImmutableList());\n            }\n            if (functions.isEmpty()) {\n                String types = node.getParameterTypes().map(parameterTypes -> format(\"(%s)\", Joiner.on(\", \").join(parameterTypes))).orElse(\"\");\n                throw new PrestoException(FUNCTION_NOT_FOUND, format(\"Function not found: %s%s\", functionName, types));\n            }\n\n            ImmutableList.Builder<Expression> rows = ImmutableList.builder();\n            for (SqlFunction function : functions) {\n                if (!(function instanceof SqlInvokedFunction)) {\n                    throw new PrestoException(GENERIC_USER_ERROR, \"SHOW CREATE FUNCTION is only supported for SQL functions\");\n                }\n\n                SqlInvokedFunction sqlFunction = (SqlInvokedFunction) function;\n                boolean temporary = sqlFunction.getFunctionId().getFunctionName().getCatalogSchemaName().equals(SESSION_NAMESPACE);\n                CreateFunction createFunction = new CreateFunction(\n                        node.getName(),\n                        false,\n                        temporary,\n                        sqlFunction.getParameters().stream()\n                                .map(parameter -> new SqlParameterDeclaration(new Identifier(parameter.getName()), parameter.getType().toString()))\n                                .collect(toImmutableList()),\n                        sqlFunction.getSignature().getReturnType().toString(),\n                        Optional.of(sqlFunction.getDescription()),\n                        new RoutineCharacteristics(\n                                new Language(sqlFunction.getRoutineCharacteristics().getLanguage().getLanguage()),\n                                Determinism.valueOf(sqlFunction.getRoutineCharacteristics().getDeterminism().name()),\n                                NullCallClause.valueOf(sqlFunction.getRoutineCharacteristics().getNullCallClause().name())),\n                        sqlParser.createReturn(sqlFunction.getBody(), createParsingOptions(session, warningCollector)));","sourceCodeStart":648,"sourceCodeEnd":684,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java#L648-L684","documentation":"The matched function is not a SqlInvokedFunction (SQL-language CREATE FUNCTION), so Presto cannot produce CREATE FUNCTION DDL for it. SHOW CREATE FUNCTION only supports user-defined SQL functions; built-in/native or connector-provided functions have no SQL body to render, hence GENERIC_USER_ERROR.","triggerScenarios":"SHOW CREATE FUNCTION on a built-in function (e.g. abs, max) or any function implemented in Java rather than declared via CREATE FUNCTION.","commonSituations":"Trying to inspect built-in function definitions; plugins registering native functions the user assumed were SQL functions; session functions vs catalog functions confusion.","solutions":["Use SHOW FUNCTIONS or documentation to inspect built-ins; their source is not retrievable via SQL","Only run SHOW CREATE FUNCTION against functions you created with CREATE FUNCTION","Check the function kind column in SHOW FUNCTIONS output before attempting the statement"],"exampleFix":"// before\nSHOW CREATE FUNCTION abs(double)   -- built-in, native\n// after\nSHOW CREATE FUNCTION my_schema.safe_div(double, double)  -- SQL UDF","handlingStrategy":"validation","validationCode":"-- 'SQL' in routine_body indicates a SHOW CREATE FUNCTION candidate\nSELECT routine_name, routine_body, function_type FROM information_schema.functions\nWHERE routine_name = 'safe_div';","typeGuard":null,"tryCatchPattern":"try { session.execute(\"SHOW CREATE FUNCTION \" + name); } catch (PrestoException e) { if (e.getErrorCode() == GENERIC_USER_ERROR.toErrorCode()) { /* use SHOW FUNCTIONS / docs for native functions */ } throw e; }","preventionTips":["Only target functions created via CREATE FUNCTION","Check the function kind/body column in SHOW FUNCTIONS first","Treat built-ins as read-only via documentation, not DDL"],"tags":["presto","sql","unsupported-feature","udf"],"backgroundTag":"unsupported-statement","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"}