{"record":{"id":"b9fd6ca8c202ef62","repo":"prestodb/presto","slug":"table-function-implementation-error","errorCode":"TABLE_FUNCTION_IMPLEMENTATION_ERROR","errorMessage":"Table function %s specifies required columns from table argument %s which cannot be found","messagePattern":"Table function (.+?) specifies required columns from table argument (.+?) which cannot be found","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java","lineNumber":1865,"sourceCode":"                    connectorId,\n                    function.getName(),\n                    argumentsAnalysis.getPassedArguments(),\n                    orderedTableArguments.build(),\n                    functionAnalysis.getRequiredColumns(),\n                    copartitioningLists,\n                    properColumnsDescriptor == null ? 0 : properColumnsDescriptor.getFields().size(),\n                    functionAnalysis.getHandle(),\n                    transactionHandle));\n\n            return createAndAssignScope(node, scope, fields.build());\n        }\n\n        private void verifyRequiredColumns(TableFunctionInvocation node, Map<String, List<Integer>> requiredColumns, Map<String, TableArgumentAnalysis> tableArgumentsByName)\n        {\n            Set<String> allInputs = ImmutableSet.copyOf(tableArgumentsByName.keySet());\n            requiredColumns.forEach((name, columns) -> {\n                if (!allInputs.contains(name)) {\n                    throw new SemanticException(TABLE_FUNCTION_IMPLEMENTATION_ERROR, \"Table function %s specifies required columns from table argument %s which cannot be found\", node.getName(), name);\n                }\n                if (columns.isEmpty()) {\n                    throw new SemanticException(TABLE_FUNCTION_IMPLEMENTATION_ERROR, \"Table function %s specifies empty list of required columns from table argument %s\", node.getName(), name);\n                }\n                // the scope is recorded, because table arguments are already analyzed\n                Scope inputScope = analysis.getScope(tableArgumentsByName.get(name).getRelation());\n                columns.stream()\n                        .filter(column -> column < 0 || column >= inputScope.getRelationType().getVisibleFieldCount())\n                        .findFirst()\n                        .ifPresent(column -> {\n                            throw new SemanticException(TABLE_FUNCTION_IMPLEMENTATION_ERROR, \"Invalid index: %s of required column from table argument %s\", column, name);\n                        });\n            });\n            Set<String> requiredInputs = ImmutableSet.copyOf(requiredColumns.keySet());\n            allInputs.stream()\n                    .filter(input -> !requiredInputs.contains(input))\n                    .findFirst()\n                    .ifPresent(input -> {","sourceCodeStart":1847,"sourceCodeEnd":1883,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java#L1847-L1883","documentation":"Analysis error for a table function invocation: the function's declared required-columns descriptor names columns that do not exist in the corresponding table argument's schema. The connector's table function metadata is inconsistent with the passed table argument.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java:1865 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the required-columns descriptor in the table function implementation to reference existing columns","Verify the table argument actually exposes the expected column names","Recreate/refresh the table function definition in the connector"],"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"}