{"record":{"id":"6f40823682fa9a95","repo":"prestodb/presto","slug":"table-function-invalid-table-function-invocation","errorCode":"TABLE_FUNCTION_INVALID_TABLE_FUNCTION_INVOCATION","errorMessage":"Alias specified for table function with ONLY PASS THROUGH return type","messagePattern":"Alias specified for table function with ONLY PASS THROUGH return type","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java","lineNumber":1895,"sourceCode":"                        });\n            });\n            Set<String> requiredInputs = ImmutableSet.copyOf(requiredColumns.keySet());\n            allInputs.stream()\n                    .filter(input -> !requiredInputs.contains(input))\n                    .findFirst()\n                    .ifPresent(input -> {\n                        throw new SemanticException(TABLE_FUNCTION_IMPLEMENTATION_ERROR, \"Table function %s does not specify required input columns from table argument %s\", node.getName(), input);\n                    });\n        }\n\n        private Descriptor verifyProperColumnsDescriptor(TableFunctionInvocation node, ConnectorTableFunction function, ReturnTypeSpecification returnTypeSpecification, Optional<Descriptor> analyzedProperColumnsDescriptor)\n        {\n            switch (returnTypeSpecification.getReturnType()) {\n                case \"PASSTHROUGH\":\n                    if (analysis.isAliased(node)) {\n                        // According to SQL standard ISO/IEC 9075-2, 7.6 <table reference>, p. 409,\n                        // table alias is prohibited for a table function with ONLY PASS THROUGH returned type.\n                        throw new SemanticException(TABLE_FUNCTION_INVALID_TABLE_FUNCTION_INVOCATION, node, \"Alias specified for table function with ONLY PASS THROUGH return type\");\n                    }\n                    if (analyzedProperColumnsDescriptor.isPresent()) {\n                        // If a table function has ONLY PASS THROUGH returned type, it does not produce any proper columns,\n                        // so the function's analyze() method should not return the proper columns descriptor.\n                        throw new SemanticException(TABLE_FUNCTION_AMBIGUOUS_RETURN_TYPE, node, \"Returned relation type for table function %s is ambiguous\", node.getName());\n                    }\n                    if (function.getArguments().stream()\n                            .filter(TableArgumentSpecification.class::isInstance)\n                            .map(TableArgumentSpecification.class::cast)\n                            .noneMatch(TableArgumentSpecification::isPassThroughColumns)) {\n                        // According to SQL standard ISO/IEC 9075-2, 10.4 <routine invocation>, p. 764,\n                        // if there is no generic table parameter that specifies PASS THROUGH, then number of proper columns shall be positive.\n                        // For GENERIC_TABLE and DescribedTable returned types, this is enforced by the Descriptor constructor, which requires positive number of fields.\n                        // Here we enforce it for the remaining returned type specification: ONLY_PASS_THROUGH.\n                        throw new SemanticException(TABLE_FUNCTION_IMPLEMENTATION_ERROR, \"A table function with ONLY_PASS_THROUGH return type must have a table argument with pass-through columns.\");\n                    }\n                    return null;\n                case \"GENERIC\":","sourceCodeStart":1877,"sourceCodeEnd":1913,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java#L1877-L1913","documentation":"Analysis error: an alias was supplied for a table function whose return type is ONLY PASS THROUGH. Pass-through functions return the descriptor of their table argument verbatim, so a table alias on the invocation itself is meaningless and is rejected.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java:1895 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the alias from the table function invocation","Use the column names coming from the pass-through table argument directly","Wrap the invocation in a subquery with aliases if renaming is needed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}