Skip to content

sql: apply SELECT list table functions after the reduce#37856

Open
def- wants to merge 1 commit into
MaterializeInc:mainfrom
def-:pr-sql-479
Open

sql: apply SELECT list table functions after the reduce#37856
def- wants to merge 1 commit into
MaterializeInc:mainfrom
def-:pr-sql-479

Conversation

@def-

@def- def- commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

A table function in the SELECT list was always joined to the FROM relation before planning GROUP BY, aggregates, and HAVING. The reduce then removed the function's columns from scope, so planning the SELECT list failed with column "table_func_0" does not exist.

Join the table functions on top of the reduce instead, so they apply to the reduced rows and their arguments can refer to grouping columns. The pre-reduce join is kept when a group key or an aggregate references the functions' columns, e.g. when grouping by a SELECT list alias of a table function, so that grouping over a function's output keeps working.

Closes: SQL-479

A table function in the SELECT list was always joined to the FROM
relation before planning GROUP BY, aggregates, and HAVING. The reduce
then removed the function's columns from scope, so planning the SELECT
list failed with `column "table_func_0" does not exist`.

Join the table functions on top of the reduce instead, so they apply
to the reduced rows and their arguments can refer to grouping columns.
The pre-reduce join is kept when a group key or an aggregate references
the functions' columns, e.g. when grouping by a SELECT list alias of a
table function, so that grouping over a function's output keeps
working.

Closes: SQL-479

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@def-
def- requested a review from ggevay July 24, 2026 09:03
@def-
def- requested a review from a team as a code owner July 24, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant