feat(duckdb): transpile BigQuery ARRAY_CONCAT_AGG to DuckDB#7891
Draft
sirockin wants to merge 3 commits into
Draft
feat(duckdb): transpile BigQuery ARRAY_CONCAT_AGG to DuckDB#7891sirockin wants to merge 3 commits into
sirockin wants to merge 3 commits into
Conversation
…IST(...)) BigQuery's `ARRAY_CONCAT_AGG(expr)` concatenates arrays into a single flat array. DuckDB has no direct equivalent, but `FLATTEN(LIST(expr))` achieves the same result: `LIST` collects the arrays into a nested list, then `FLATTEN` unnests one level. Adds: - `ARRAY_CONCAT_AGG` → `FLATTEN(LIST(...))` mapping in DuckDB generator - Transpilation test (BigQuery → DuckDB round-trip)
geooo109
reviewed
Jul 17, 2026
geooo109
left a comment
Collaborator
There was a problem hiding this comment.
ARRAY_CONCAT_AGG(
expression
[ ORDER BY key [ { ASC | DESC } ] [, ... ] ]
[ LIMIT n ]
)
From the docs ^ of bq, so let's also check what happens in the case of ORDER BY case and the LIMIT n.
- Replace FLATTEN(LIST(x)) with FLATTEN(ARRAY_AGG(x) FILTER(WHERE NOT x IS NULL)) so all-NULL inputs return NULL (matching BigQuery) - Use expression API via new arrayconcatagg_sql method instead of inline lambda with f-string - Fix test input to use valid BigQuery syntax (ARRAY_CONCAT_AGG requires an array argument, not a scalar) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
geooo109
reviewed
Jul 20, 2026
- Remove ArrayConcatAgg from TRANSFORMS dict (auto-discovered via
method name convention)
- Use self.func("FLATTEN", ...) instead of self.sql(exp.Flatten(...))
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
@sirockin is this still a draft? What's pending? |
Collaborator
|
@georgesittas we should check the I think |
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
BigQuery's
ARRAY_CONCAT_AGG(expr)concatenates arrays into a single flat array. DuckDB has no direct equivalent, butFLATTEN(LIST(expr))achieves the same result:LISTcollects the arrays into a nested list, thenFLATTENunnests one level.Changes
ARRAY_CONCAT_AGG→FLATTEN(LIST(...))mapping inDuckDB.GeneratorMotivation
We use sqlglot to transpile BigQuery SQL models to DuckDB for local testing via sqlmesh.
ARRAY_CONCAT_AGGis used in several of our production models but was not previously transpiled.