Skip to content

feat: convert TABLE(FLATTEN(...)) after a comma - #106

Closed
kvlonge wants to merge 4 commits into
mainfrom
feat/table-flatten
Closed

kvlonge wants to merge 4 commits into
mainfrom
feat/table-flatten

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Why

, TABLE(FLATTEN(input => ...)) f after a comma is a common way to explode an array in dbt models, and it was refused as a missing rule.

Changes

  • TABLE(FLATTEN(...)) with an alias and no column list, after another FROM source as a comma or CROSS JOIN source, converts the same way as LATERAL FLATTEN, which it correlates like.
  • The FLATTEN rule's catalogue conditions say so.
  • New recorded cases: cases/semi-structured/table_flatten.toml (2 cases, positional array and named VARIANT path), with Snowflake receipts.

Verification

  • Local replay of every recorded case: 8,476 cases, 0 failed; both new cases pass.
  • Static checks pass locally. Merge gate before landing.

Snowflake correlates TABLE(FLATTEN(t.col)) f to the sources before it, as
dbt models write it; it now converts through the LATERAL FLATTEN rule,
with a positional or named input.
Snowflake results for the six cases in cases/relational/pivot_unaliased.toml and cases/semi-structured/table_flatten.toml at a20177b.

kvlonge commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing: SQLQuack lands through local-gate trains, not PR merges (D94), so open PRs only add clutter (D628/D630). The branch is kept. Any work here that isn't on main yet is tracked by the train owner and lands through a train.

@kvlonge kvlonge closed this Nov 8, 2026
kvlonge added a commit that referenced this pull request Nov 9, 2026
D591's function conversion moves into sqlquack-convert's Snowflake
analysis, beside analyze and analyze_function, with this branch's crate
paths.
@kvlonge
kvlonge deleted the feat/table-flatten branch November 9, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant