Repository navigation
Derive a FLATTEN's KEY and PATH from its input - #7
Merged
Merged
Conversation
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>
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.
Patch 8 of the engine fork that collin pins (dbt-collin decision 0028): a
LATERAL FLATTEN'sKEYandPATHnow derive from its input, asVALUEandTHISalready 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.keyread nothing.The change
KEYandPATHderive from the columns the input reads, with the call as their expression.SEQandINDEXnumber the rows and the elements, and still read nothing.Tests
KEY,PATHandVALUEall come fromhx.data, andINDEXfrom nothing. It fails without the patch.snowflake_lateral_flattensnapshot gains the two edges intoKEYandPATH.cargo fmt --checkis clean.Measured through collin
These figures come with collin's companion change, which treats
SEQandINDEXas positions, so as roots.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