Skip to content

Derive a FLATTEN's KEY and PATH from its input - #7

Merged
IL-William merged 1 commit into
masterfrom
fix/flatten-key-path-master
Oct 10, 2026
Merged

IL-William merged 1 commit into
masterfrom
fix/flatten-key-path-master

Conversation

@IL-William

Copy link
Copy Markdown
Owner

Patch 8 of the engine fork that collin pins (dbt-collin decision 0028): a LATERAL FLATTEN's KEY and PATH now derive from its input, as VALUE and THIS already do.

A key and a path name where an element sits in the input. For an object, they are part of its content: flatten JSON parsed from a column, and the keys are data of that column. Until now f.key read nothing.

The change

  • KEY and PATH derive from the columns the input reads, with the call as their expression.
  • SEQ and INDEX number the rows and the elements, and still read nothing.
  • Each column carrying the input reads the same input, so an issue about resolving it is reported once, by the first.

Tests

  • A new test: KEY, PATH and VALUE all come from hx.data, and INDEX from nothing. It fails without the patch.
  • The two tests that pinned the old split are updated.
  • The snowflake_lateral_flatten snapshot gains the two edges into KEY and PATH.
  • 2621 tests pass, and cargo fmt --check is clean.

Measured through collin

These figures come with collin's companion change, which treats SEQ and INDEX as positions, so as roots.

Project Effect
3507 model Snowflake project 402 parsed edges added and none removed; columns lost in trusted models go from 4 to 0
Cal-ITP (BigQuery) cache identical
Shopify (DuckDB) cache identical

sqlglot reads every collin edge of the affected models the same way.

Nothing goes to pondpilot/flowscope.

🤖 Generated with Claude Code

https://claude.ai/code/session_017VTEw2dNNL9Pn57Hkeeirn

LATERAL FLATTEN's KEY and PATH read nothing, as SEQ and INDEX do. But a
key and a path name where an element sits in the input, and for an object
that is part of its content: flattening parsed JSON, the keys are data of
the column the JSON is in.

    SELECT f.key AS element_name, f.value::STRING AS element_value
    FROM hx h, LATERAL FLATTEN(input => TRY_PARSE_JSON(h.data)) f

element_value came out derived from hx.data and element_name from
nothing.

KEY and PATH now derive from the columns the input reads, with the call
as their expression, as VALUE and THIS already did. SEQ and INDEX number
the rows and the elements and still read nothing. Each column carrying the
input reads the same input, so whatever resolving it reports is reported
once, by the first.

Tests: the query above, the key, the path and the value from hx.data and
the index from nothing; the tests pinning the old split now expect KEY and
PATH among the columns fed by the input. The snowflake_lateral_flatten
snapshot gains the two edges into KEY and PATH.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@IL-William
IL-William merged commit 0c68196 into master Oct 10, 2026
8 checks passed
@IL-William
IL-William deleted the fix/flatten-key-path-master branch October 10, 2026 19:02
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