feat(codegen/go): PoC for opt-in iter.Seq2 companions on :many queries#4488
Open
Tilzen wants to merge 2 commits into
Open
feat(codegen/go): PoC for opt-in iter.Seq2 companions on :many queries#4488Tilzen wants to merge 2 commits into
Tilzen wants to merge 2 commits into
Conversation
Implement emit_iterators PoC from docs/emit-iterators-prd.md: lazy iter.Seq2[T, error] methods alongside existing slice APIs, with global or explicit_only scope and :stream / :many:stream query annotations. Includes stdlib and pgx templates, config options, end-to-end testdata, and codegen integration tests.
…rix tests Add SQLite runtime tests (parity, lazy start, early break, parameterized queries), codegen matrix for global/explicit/pgx/disabled scenarios, opts validation tests, and golden replay fixtures for all cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Revives the long-standing request for streaming/lazy
:manyquery results (#720). Today, sqlc always materializes:manyinto[]T, which is fine for small result sets but costly for exports, sync jobs, and backfills.Go 1.23+ shipped native iterators (
iter.Seq2). Kyle noted that this unblocks native iterator generation; PR #3631 explored an implementation but closed without merge after API design remained open.This PR is not a merge-ready feature. It is a proof of concept (PoC) posted for design feedback before investing in a production implementation. See the discussion proposal in #720 and related #4464.
PoC reference (fork): https://github.com/Tilzen/sqlc/tree/feat/emit-iterators-poc
PRD in PoC branch:
docs/emit-iterators-prd.mdWhat Changed (PoC scope)
Opt-in config (zero breaking changes to default
:many→[]T):Generates a lazy companion alongside existing slice methods:
Also supports query annotations for
explicit_onlyscope:-- name: StreamAuthors :stream-- name: ListAuthors :many:streamPoC includes: stdlib + pgx/v5 templates, metadata parsing, config wiring, PRD doc.
Explicitly out of PoC scope:
callback/rowsstyles, eager mode,emit_interfaceiter methods, Python/Kotlin generators, full driver matrix.Open Design Questions (feedback welcome)
ItervsStream?emit_iterators: globaland:streamannotations?:streamremain a separate query kind or only:many:stream?Test Plan
PoC test coverage (all passing on the fork branch):
:stream,:many:stream),emit_iterators: falseregression, parameterized:many, pgx/v5TestReplay/emit_iterators*fixturesrange), earlybreak+ connection reuse, parameterized queriesReferences
Notes
seq2+ lazy +Iterprefix), I can refine the PoC toward a production-ready PR in follow-up commits.