prestodb/presto · error · PrestoException
INVALID_FUNCTION_ARGUMENT
INVALID_FUNCTION_ARGUMENT
Error message
Start is null
What it means
The sequence table function (sequence(start, stop[, step])) requires non-NULL start, stop, and step scalar arguments. During analysis it unwraps each argument value and throws INVALID_FUNCTION_ARGUMENT if any is NULL. SQL NULLs passed as literals or parameters are rejected before execution.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/table/Sequence.java:107
.build(),
ScalarArgumentSpecification.builder()
.name(STOP_ARGUMENT_NAME)
.type(BIGINT)
.build(),
ScalarArgumentSpecification.builder()
.name(STEP_ARGUMENT_NAME)
.type(BIGINT)
.defaultValue(1L)
.build()),
new DescribedTableReturnTypeSpecification(descriptor(ImmutableList.of("sequential_number"), ImmutableList.of(BIGINT))));
}
@Override
public TableFunctionAnalysis analyze(ConnectorSession session, ConnectorTransactionHandle transaction, Map<String, Argument> arguments)
{
Object startValue = ((ScalarArgument) arguments.get(START_ARGUMENT_NAME)).getValue();
if (startValue == null) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Start is null");
}
Object stopValue = ((ScalarArgument) arguments.get(STOP_ARGUMENT_NAME)).getValue();
if (stopValue == null) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Stop is null");
}
Object stepValue = ((ScalarArgument) arguments.get(STEP_ARGUMENT_NAME)).getValue();
if (stepValue == null) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Step is null");
}
long start = (long) startValue;
long stop = (long) stopValue;
long step = (long) stepValue;
if (start < stop && step <= 0) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Step must be positive for sequence [%s, %s]", start, stop));View on GitHub (pinned to 55bb57d202)
Solutions
- Ensure the start argument is a non-NULL literal or expression, e.g. use 1 instead of NULL.
- Wrap potentially-NULL inputs: since table function arguments are constant scalars, resolve the NULL in application code or with a default before building the query.
- If the value comes from a parameter, add an application-side check/default (e.g. start ?? 1).
- Fix the upstream expression or column that yields NULL for the start value.
Example fix
// before TABLE(sequence(start => NULL, stop => 10)) // after TABLE(sequence(start => 1, stop => 10))
Defensive patterns
Strategy: validation
Validate before calling
// Reject NULL bounds before building the query:
if (start == null) {
throw new IllegalArgumentException("sequence start must be non-null");
}
String sql = "SELECT * FROM TABLE(sequence(start => " + start + ", stop => " + stop + "))"; Type guard
boolean isValidStart(Object start) {
return start instanceof Long || start instanceof Integer;
} Try / catch
try {
runTableFunctionQuery(sequenceSql);
} catch (PrestoException e) {
if (e.getErrorCode().getCode() == StandardErrorCode.INVALID_FUNCTION_ARGUMENT.toErrorCode().getCode()
&& e.getMessage().contains("Start is null")) {
// substitute a default start (e.g. 1) and retry
}
throw e;
} Prevention
- Default NULL parameters at the application layer before binding them to table function arguments.
- Validate that start/stop/step are non-null longs before generating sequence queries.
- Avoid passing optional bounds as NULL; build the query conditionally instead.
When it happens
Trigger: Calling TABLE(sequence(start => NULL, stop => <value>)) or passing a NULL-typed parameter/prepared-statement placeholder as the START argument of the sequence table function.
Common situations: Binding an unset application variable as the start parameter; a NULL produced by a subquery/expression feeding the argument; COALESCE/defaults missing in generated SQL.
Related errors
- INVALID_FUNCTION_ARGUMENT
- Timeout is negative
- ALREADY_EXISTS
- FUNCTION_NOT_FOUND
- FUNCTION_IMPLEMENTATION_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/82e5ea8ed987a86b.
Report an issue: GitHub.