{"record":{"id":"82e5ea8ed987a86b","repo":"prestodb/presto","slug":"invalid-function-argument-82e5ea","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"Start is null","messagePattern":"Start is null","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/table/Sequence.java","lineNumber":107,"sourceCode":"                                    .build(),\n                            ScalarArgumentSpecification.builder()\n                                    .name(STOP_ARGUMENT_NAME)\n                                    .type(BIGINT)\n                                    .build(),\n                            ScalarArgumentSpecification.builder()\n                                    .name(STEP_ARGUMENT_NAME)\n                                    .type(BIGINT)\n                                    .defaultValue(1L)\n                                    .build()),\n                    new DescribedTableReturnTypeSpecification(descriptor(ImmutableList.of(\"sequential_number\"), ImmutableList.of(BIGINT))));\n        }\n\n        @Override\n        public TableFunctionAnalysis analyze(ConnectorSession session, ConnectorTransactionHandle transaction, Map<String, Argument> arguments)\n        {\n            Object startValue = ((ScalarArgument) arguments.get(START_ARGUMENT_NAME)).getValue();\n            if (startValue == null) {\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, \"Start is null\");\n            }\n\n            Object stopValue = ((ScalarArgument) arguments.get(STOP_ARGUMENT_NAME)).getValue();\n            if (stopValue == null) {\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, \"Stop is null\");\n            }\n\n            Object stepValue = ((ScalarArgument) arguments.get(STEP_ARGUMENT_NAME)).getValue();\n            if (stepValue == null) {\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, \"Step is null\");\n            }\n\n            long start = (long) startValue;\n            long stop = (long) stopValue;\n            long step = (long) stepValue;\n\n            if (start < stop && step <= 0) {\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format(\"Step must be positive for sequence [%s, %s]\", start, stop));","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/table/Sequence.java#L89-L125","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nTABLE(sequence(start => NULL, stop => 10))\n// after\nTABLE(sequence(start => 1, stop => 10))","handlingStrategy":"validation","validationCode":"// Reject NULL bounds before building the query:\nif (start == null) {\n    throw new IllegalArgumentException(\"sequence start must be non-null\");\n}\nString sql = \"SELECT * FROM TABLE(sequence(start => \" + start + \", stop => \" + stop + \"))\";","typeGuard":"boolean isValidStart(Object start) {\n    return start instanceof Long || start instanceof Integer;\n}","tryCatchPattern":"try {\n    runTableFunctionQuery(sequenceSql);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getCode() == StandardErrorCode.INVALID_FUNCTION_ARGUMENT.toErrorCode().getCode()\n            && e.getMessage().contains(\"Start is null\")) {\n        // substitute a default start (e.g. 1) and retry\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["presto","table-function","null-argument","invalid-argument"],"backgroundTag":"null-argument","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"}