Skip to content

feat(substrait): fork consumers for concurrent relation inputs - #26896

Draft
alexanderbianchi wants to merge 4 commits into
apache:mainfrom
alexanderbianchi:codex/substrait-consumer-forks
Draft

alexanderbianchi wants to merge 4 commits into
apache:mainfrom
alexanderbianchi:codex/substrait-consumer-forks

Conversation

@alexanderbianchi

@alexanderbianchi alexanderbianchi commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #26602. Stacked on #26603; merge the input hook first. Both PRs target Apache main, so this draft includes the prerequisite commit. Fork-only diff.

Rationale for this change

Concurrent inputs cannot safely share mutable lambda and outer-query scope stacks. Consumers need a way to give each branch its own scope.

What changes are included in this PR?

Add optional fork_for_branch() -> Option<Self>. consume_rel_inputs consumes isolated forks concurrently when all inputs can be forked, otherwise it stays sequential. The default consumer implements forking by copying scope stacks and sharing session configuration.

This extracts the fork approach previously included in #26603. Table caching and lookup limits remain separate in #26680; #26890 explores explicit contexts instead.

What is the testing strategy for this PR?

Existing tests cover sequential fallback, concurrent completion in input order, cancellation on error, and inherited but independent scopes. The updated hook prerequisite passes the extended workspace suite (12,896 Rust tests and 540 SQL logic files). The combined fork branch passes formatting, workspace Clippy, 73 Substrait unit tests, 228 integration tests, and 3 doctests.

Are there any user-facing changes?

The default consumer consumes independent JOIN, CROSS JOIN, set-operation, and multi-input extension children concurrently. Custom consumers remain sequential unless they implement the fork hook or override consume_rel_inputs. Existing implementations remain source-compatible.

@alexanderbianchi
alexanderbianchi force-pushed the codex/substrait-consumer-forks branch from fd1057f to cc2c877 Compare October 29, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant