Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
The vectorised list_cat approach processes all rows in a single pipeline pass. Depth defaults to 5 and is configurable via _nestedRepeatDepth. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
For top-level repeats (not inside a lambda), emit each depth level as a lateral SELECT column alias instead of inlining the full expression into every list_cat argument. This avoids re-evaluating ancestor levels and makes DuckDB's deduplication explicit rather than relying on the optimizer. Falls back to inline unrolling inside lambda scope (forEach, nested repeat) where lateral aliases cannot reference lambda variables. Also removes the double null-guard: _col_collection no longer appends .ifnull2([]) when the value's outputType.nullHandled is already true, eliminating the redundant coalesce(...,[]).ifnull2([]) chain emitted by _repeat. Benchmarks show no measurable runtime difference on the QuestionnaireResponse repeat_view (ndjson ~9.6s, parquet ~97s), indicating DuckDB already CSEs the inline expressions. The structural improvement still stands for correctness and future query plan legibility. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Three bugs in ddb-sql-builder.js:
1. buildRepeatTransformSchema didn't walk _unionAll branches, producing an
empty JSON schema ({}) when a repeat's column arg contained a unionAll.
2. A standalone _forEach inside a _repeat lambda (e.g. a unionAll branch
inside repeat) incorrectly tried to iterate via _ri.as_list().list_transform
instead of projecting the current item as a plain struct.
3. nav with inputType.json=true (a JSON[] repeat entry field accessed outside
a lambda) generated el.field instead of el->>'field', causing a DuckDB
conversion error when a non-repeat unionAll branch navigated into that field.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Exposes the previously internal _nestedRepeatDepth option as a proper user-facing flag. Threads repeatDepth through templateToQuery and buildQuery into astToSql options, and documents it in the README. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
repeatdirective, which performs recursive traversal of nested structures (e.g.Questionnaire.item)list_catunrolling with lateral column aliases for top-level repeats (evaluated once per row) and inline unrolling inside lambda scopesunionAllinsiderepeatand mixed repeat/non-repeatunionAllbranches--repeat-depthCLI flag (default: 5) to control maximum traversal depthTest plan
bun test— all 226 tests passrepeatagainst real Questionnaire/QuestionnaireResponse NDJSON data--repeat-depth 10increases traversal depth for deeply nested structures🤖 Generated with Claude Code