Skip to content

Add ROWS FROM table function support#3412

Draft
myers wants to merge 2 commits intodolthub:mainfrom
myers:rows-from-table-function
Draft

Add ROWS FROM table function support#3412
myers wants to merge 2 commits intodolthub:mainfrom
myers:rows-from-table-function

Conversation

@myers
Copy link

@myers myers commented Feb 1, 2026

Summary

Adds ROWS FROM table function support for executing multiple set-returning functions in parallel and zipping their results together.

  • Add plan.RowsFrom node for ROWS FROM table expressions
  • Add RowsFromRowIter to execute multiple SRFs in parallel with NULL padding
  • Add buildRowsFrom in planbuilder to handle RowsFromExpr
  • Register RowsFrom in node builder

This enables PostgreSQL-compatible ROWS FROM syntax:

SELECT * FROM ROWS FROM(func1(...), func2(...))

When one function is exhausted before another, NULL is used for padding.

Related PRs

Test plan

  • Tests in doltgresql repository cover multi-argument UNNEST and ROWS FROM functionality

Implements plan.RowsFrom node and RowsFromRowIter for executing
multiple set-returning functions in parallel and zipping their
results together. When one function is exhausted before another,
NULL is used for padding.

This enables PostgreSQL-compatible ROWS FROM syntax:
  SELECT * FROM ROWS FROM(func1(...), func2(...))

Also supports WITH ORDINALITY and column aliases.
myers added a commit to myers/doltgresql that referenced this pull request Feb 1, 2026
Expands multi-argument UNNEST(arr1, arr2, ...) into
ROWS FROM(unnest(arr1), unnest(arr2), ...) which properly
zips results together with NULL padding for shorter arrays.

Changes:
- table_expr.go: Detect and expand multi-arg UNNEST to RowsFromExpr
- aliased_table_expr.go: Support WITH ORDINALITY via RowsFromExpr
- select_clause.go: Update multi-arg UNNEST rewrite to use RowsFromExpr

Depends on:
- dolthub/vitess#454
- dolthub/go-mysql-server#3412
myers added a commit to myers/doltgresql that referenced this pull request Feb 3, 2026
- Add comprehensive tests for explicit ROWS FROM syntax:
  - ROWS FROM with generate_series
  - ROWS FROM with unnest
  - ROWS FROM with mixed functions
- Fix table_expr.go and aliased_table_expr.go to use RowsFromExpr
  for all multi-function ROWS FROM cases, not just multi-arg UNNEST

Depends on:
- dolthub/vitess#454
- dolthub/go-mysql-server#3412
Add BuildMultiExprTableFunc factory variable for nameless TableFuncExpr
(ROWS FROM pattern), overridable by Doltgres. Remove plan.RowsFrom and
RowsFromIter which move to doltgresql as an ExecBuilderNode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants