prestodb/presto · error · SemanticException
TABLE_FUNCTION_COLUMN_NOT_FOUND
TABLE_FUNCTION_COLUMN_NOT_FOUND
Error message
Column %s is not present in the input relation
What it means
A column reference given to a table function argument could not be resolved as a local field of the input relation. tryResolveField either found nothing or resolved a field from an outer scope (isLocal() false), so the analyzer reports that the column does not exist in the input table argument.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java:2230
.orElse(NULL_DESCRIPTOR),
Optional.empty());
}
private Field validateAndGetInputField(Expression expression, Scope inputScope)
{
QualifiedName qualifiedName;
if (expression instanceof Identifier) {
qualifiedName = QualifiedName.of(ImmutableList.of(((Identifier) expression)));
}
else if (expression instanceof DereferenceExpression) {
qualifiedName = getQualifiedName((DereferenceExpression) expression);
}
else {
throw new SemanticException(TABLE_FUNCTION_INVALID_COLUMN_REFERENCE, expression, "Expected column reference. Actual: %s", expression);
}
Optional<ResolvedField> field = inputScope.tryResolveField(expression, qualifiedName);
if (!field.isPresent() || !field.get().isLocal()) {
throw new SemanticException(TABLE_FUNCTION_COLUMN_NOT_FOUND, expression, "Column %s is not present in the input relation", expression);
}
return field.get().getField();
}
private List<List<String>> analyzeCopartitioning(List<List<QualifiedName>> copartitioning, List<TableArgumentAnalysis> tableArgumentAnalyses)
{
// map table arguments by relation names. usa a multimap, because multiple arguments can have the same value, e.g. input_1 => tpch.tiny.orders, input_2 => tpch.tiny.orders
ImmutableMultimap.Builder<QualifiedName, TableArgumentAnalysis> unqualifiedInputsBuilder = ImmutableMultimap.builder();
ImmutableMultimap.Builder<QualifiedName, TableArgumentAnalysis> qualifiedInputsBuilder = ImmutableMultimap.builder();
tableArgumentAnalyses.stream()
.filter(argument -> argument.getName().isPresent())
.forEach(argument -> {
QualifiedName name = argument.getName().get();
if (name.getParts().size() == 1) {
unqualifiedInputsBuilder.put(name, argument);
}
else if (name.getParts().size() == 3) {View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the column exists in the passed relation with SHOW COLUMNS or DESC.
- Fix the column name spelling or qualification (table.column).
- If the column comes from an outer scope, project it into the input subquery explicitly.
- Ensure the input subquery selects the columns the function arguments reference.
Example fix
// before TABLE(fn(input => (SELECT a FROM t), key => missing_col)) // after TABLE(fn(input => (SELECT a, missing_col FROM t), key => missing_col))
Defensive patterns
Strategy: validation
Validate before calling
// Check that every referenced column exists in the relation passed as the table argument
Set<String> inputColumns = describeColumns(inputRelation); // e.g. via SHOW COLUMNS metadata
for (String col : referencedColumns) {
String simple = col.contains(".") ? col.substring(col.lastIndexOf('.') + 1) : col;
if (!inputColumns.contains(simple.toLowerCase())) {
throw new IllegalArgumentException("Column " + col + " is not present in the input relation");
}
} Prevention
- Run SHOW COLUMNS on the input relation before referencing its columns.
- Project all needed columns explicitly in the input subquery.
- Do not rely on outer-scope columns inside TABLE(...); correlate only through the passed relation.
When it happens
Trigger: Referencing a column that is not projected by the relation passed as the table argument, or referencing a column from an outer query scope (non-local field) inside the table function invocation.
Common situations: Typos in column names; assuming all columns of the underlying table are visible when a subquery only projects a few; referencing outer query columns (correlated reference) from within TABLE(...).
Related errors
- MISSING_COLUMN
- TABLE_FUNCTION_INVALID_COLUMN_REFERENCE
- TABLE_FUNCTION_INVALID_COPARTITIONING
- COLUMN_NOT_FOUND
- INVALID_TABLE_PROPERTY
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/fff7415fa875f102.
Report an issue: GitHub.