prestodb/presto · error · PrestoException
GENERIC_USER_ERROR
GENERIC_USER_ERROR
Error message
SHOW CREATE FUNCTION is only supported for SQL functions
What it means
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.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java:666
QualifiedObjectName functionName = metadata.getFunctionAndTypeManager().getFunctionAndTypeResolver().qualifyObjectName(node.getName());
Collection<? extends SqlFunction> functions = metadata.getFunctionAndTypeManager().getFunctions(session, functionName);
if (node.getParameterTypes().isPresent()) {
List<TypeSignature> parameterTypes = node.getParameterTypes().get().stream()
.map(TypeSignature::parseTypeSignature)
.collect(toImmutableList());
functions = functions.stream()
.filter(function -> function.getSignature().getArgumentTypes().equals(parameterTypes))
.collect(toImmutableList());
}
if (functions.isEmpty()) {
String types = node.getParameterTypes().map(parameterTypes -> format("(%s)", Joiner.on(", ").join(parameterTypes))).orElse("");
throw new PrestoException(FUNCTION_NOT_FOUND, format("Function not found: %s%s", functionName, types));
}
ImmutableList.Builder<Expression> rows = ImmutableList.builder();
for (SqlFunction function : functions) {
if (!(function instanceof SqlInvokedFunction)) {
throw new PrestoException(GENERIC_USER_ERROR, "SHOW CREATE FUNCTION is only supported for SQL functions");
}
SqlInvokedFunction sqlFunction = (SqlInvokedFunction) function;
boolean temporary = sqlFunction.getFunctionId().getFunctionName().getCatalogSchemaName().equals(SESSION_NAMESPACE);
CreateFunction createFunction = new CreateFunction(
node.getName(),
false,
temporary,
sqlFunction.getParameters().stream()
.map(parameter -> new SqlParameterDeclaration(new Identifier(parameter.getName()), parameter.getType().toString()))
.collect(toImmutableList()),
sqlFunction.getSignature().getReturnType().toString(),
Optional.of(sqlFunction.getDescription()),
new RoutineCharacteristics(
new Language(sqlFunction.getRoutineCharacteristics().getLanguage().getLanguage()),
Determinism.valueOf(sqlFunction.getRoutineCharacteristics().getDeterminism().name()),
NullCallClause.valueOf(sqlFunction.getRoutineCharacteristics().getNullCallClause().name())),
sqlParser.createReturn(sqlFunction.getBody(), createParsingOptions(session, warningCollector)));View on GitHub (pinned to 55bb57d202)
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
Example fix
// before SHOW CREATE FUNCTION abs(double) -- built-in, native // after SHOW CREATE FUNCTION my_schema.safe_div(double, double) -- SQL UDF
Defensive patterns
Strategy: validation
Validate before calling
-- 'SQL' in routine_body indicates a SHOW CREATE FUNCTION candidate SELECT routine_name, routine_body, function_type FROM information_schema.functions WHERE routine_name = 'safe_div';
Try / catch
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; } Prevention
- 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
When it happens
Trigger: SHOW CREATE FUNCTION on a built-in function (e.g. abs, max) or any function implemented in Java rather than declared via CREATE FUNCTION.
Common situations: Trying to inspect built-in function definitions; plugins registering native functions the user assumed were SQL functions; session functions vs catalog functions confusion.
Related errors
- SHOW CREATE only supported for tables and views
- INVALID_TABLE_PROPERTY
- NOT_SUPPORTED
- Result set type must be TYPE_FORWARD_ONLY
- Result set concurrency must be CONCUR_READ_ONLY
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/8808e8cac5893f9a.
Report an issue: GitHub.