prestodb/presto · error · SemanticException

TABLE_FUNCTION_INVALID_ARGUMENTS

TABLE_FUNCTION_INVALID_ARGUMENTS

Error message

Too many arguments. Expected at most %s arguments, got %s arguments

What it means

Analysis error for a table function invocation: more arguments were passed than the function accepts. The %s pair gives the maximum expected arity and the actual argument count; non-function arguments and descriptor arguments all count toward the total.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java:1941

                    // We don't enforce this requirement.
                    if (analyzedProperColumnsDescriptor.isPresent()) {
                        // If a table function has statically declared returned type, it is returned in TableFunctionMetadata
                        // so the function's analyze() method should not return the proper columns descriptor.
                        throw new SemanticException(TABLE_FUNCTION_AMBIGUOUS_RETURN_TYPE, node, "Returned relation type for table function %s is ambiguous", node.getName());
                    }
                    return ((DescribedTableReturnTypeSpecification) returnTypeSpecification).getDescriptor();
            }
        }

        private ArgumentsAnalysis analyzeArguments(TableFunctionInvocation node, List<ArgumentSpecification> argumentSpecifications, Optional<Scope> scope)
        {
            List<TableFunctionArgument> arguments = node.getArguments();
            Node errorLocation = node;
            if (!arguments.isEmpty()) {
                errorLocation = arguments.get(0);
            }
            if (argumentSpecifications.size() < arguments.size()) {
                throw new SemanticException(TABLE_FUNCTION_INVALID_ARGUMENTS, errorLocation, "Too many arguments. Expected at most %s arguments, got %s arguments", argumentSpecifications.size(), arguments.size());
            }

            if (argumentSpecifications.isEmpty()) {
                return new ArgumentsAnalysis(ImmutableMap.of(), ImmutableList.of());
            }

            boolean argumentsPassedByName = !arguments.isEmpty() && arguments.stream().allMatch(argument -> argument.getName().isPresent());
            boolean argumentsPassedByPosition = arguments.stream().allMatch(argument -> !argument.getName().isPresent());
            if (!argumentsPassedByName && !argumentsPassedByPosition) {
                throw new SemanticException(TABLE_FUNCTION_INVALID_ARGUMENTS, errorLocation, "All arguments must be passed by name or all must be passed positionally");
            }

            if (argumentsPassedByName) {
                return mapTableFunctionsArgsByName(argumentSpecifications, arguments, errorLocation, scope);
            }
            else {
                return mapTableFunctionArgsByPosition(argumentSpecifications, arguments, errorLocation, scope);
            }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Remove the extra arguments to match the declared signature
  2. Check the table function's documentation for its exact argument list
  3. Pass values in a single row/struct argument if grouping is needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java:1941 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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