prestodb/presto · error · IllegalArgumentException

Unsupported function kind: %s

Error message

Unsupported function kind: %s

What it means

An internal guard in the function-kind-to-string helper: the FunctionKind enum had a value with no mapped case (only AGGREGATE, WINDOW, SCALAR are handled), so an IllegalArgumentException is thrown. Users never trigger this directly; it indicates a new FunctionKind was added to the engine without updating this switch.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java:829

                                    SortItem.Ordering.ASCENDING,
                                    SortItem.NullOrdering.UNDEFINED),
                            ascending("return_type"),
                            ascending("argument_types"),
                            ascending("function_type"))));
        }

        private static String getFunctionType(SqlFunction function)
        {
            FunctionKind kind = function.getSignature().getKind();
            switch (kind) {
                case AGGREGATE:
                    return "aggregate";
                case WINDOW:
                    return "window";
                case SCALAR:
                    return "scalar";
            }
            throw new IllegalArgumentException("Unsupported function kind: " + kind);
        }

        @Override

        protected Node visitShowSession(ShowSession node, Void context)
        {
            ImmutableList.Builder<Expression> rows = ImmutableList.builder();
            SortedMap<String, ConnectorId> catalogNames = listCatalogs(session, metadata, accessControl);
            List<SessionPropertyValue> sessionProperties = metadata.getSessionPropertyManager().getAllSessionProperties(session, catalogNames);
            for (SessionPropertyValue sessionProperty : sessionProperties) {
                if (sessionProperty.isHidden()) {
                    continue;
                }

                String value = sessionProperty.getValue();
                String defaultValue = sessionProperty.getDefaultValue();
                rows.add(row(
                        new StringLiteral(sessionProperty.getFullyQualifiedName()),

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Upgrade presto-main-base / the rewrite class to a version whose switch covers all FunctionKind values
  2. Patch the switch to handle the new kind (e.g. map it to a sensible label) instead of falling through
  3. File/track the inconsistency with the FunctionKind enum definition

Example fix

// before
case SCALAR: return "scalar";
}
// after
case SCALAR: return "scalar";
case INLINE: return "inline";  // handle new kind
}
Defensive patterns

Strategy: fallback

Type guard

static boolean isRenderableKind(FunctionKind kind) {
  return kind == FunctionKind.AGGREGATE || kind == FunctionKind.WINDOW || kind == FunctionKind.SCALAR;
}

Try / catch

try { return labelFor(kind); } catch (IllegalArgumentException e) { return kind.name().toLowerCase(Locale.ROOT); }

Prevention

When it happens

Trigger: Rendering a function kind label for a FunctionKind value outside AGGREGATE/WINDOW/SCALAR (e.g. new kinds added in the enum) during SHOW FUNCTIONS or similar output paths in this visitor.

Common situations: Presto version upgrade adding a FunctionKind while this rewrite (or a fork/backport) lags behind; custom builds with an extended enum.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/c65cf1685842f376. Report an issue: GitHub.