Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,16 @@ protected Scope visitTableFunctionInvocation(TableFunctionInvocation node, Optio
// so the function's analyze() method should not return the proper columns descriptor.
throw semanticException(AMBIGUOUS_RETURN_TYPE, node, "Returned relation type for table function %s is ambiguous", node.getName());
}
if (function.getArguments().stream()
.filter(TableArgumentSpecification.class::isInstance)
.map(TableArgumentSpecification.class::cast)
.noneMatch(TableArgumentSpecification::isPassThroughColumns)) {
// According to SQL standard ISO/IEC 9075-2, 10.4 <routine invocation>, p. 764,
// if there is no generic table parameter that specifies PASS THROUGH, then number of proper columns shall be positive.
// For GENERIC_TABLE and DescribedTable returned types, this is enforced by the Descriptor constructor, which requires positive number of fields.
// Here we enforce it for the remaining returned type specification: ONLY_PASS_THROUGH.
throw new TrinoException(FUNCTION_IMPLEMENTATION_ERROR, "A table function with ONLY_PASS_THROUGH return type must have a table argument with pass-through columns.");
}
properColumnsDescriptor = null;
}
else if (returnTypeSpecification == GENERIC_TABLE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public OnlyPassThroughFunction()
ImmutableList.of(
TableArgumentSpecification.builder()
.name("INPUT")
.passThroughColumns()
.keepWhenEmpty()
.build()),
ONLY_PASS_THROUGH);
Expand Down