Uh oh!
There was an error while loading. Please reload this page.
fix(e6): alias unaliased Databricks colon projections by final path segment - #287
Open
tkaunlaky-e6 wants to merge 1 commit into
Open
fix(e6): alias unaliased Databricks colon projections by final path segment#287tkaunlaky-e6 wants to merge 1 commit into
tkaunlaky-e6 wants to merge 1 commit into
Conversation
…egment Databricks derives an implicit column name from the final segment of an unaliased colon/variant access (deep_dives:metrics_per_level -> metrics_per_level). E6 has no such rule, so an outer query that references that column by name fails with "Column not found in any table". For Databricks-sourced transpiles, make the implicit name explicit: a bare colon/variant JSONExtract that is a top-level SELECT projection is wrapped in "AS <final-segment>". Scoped to the SELECT list, so colon access inside WHERE / GROUP BY / a function / CASE, an already-aliased projection, and a path ending in a subscript are all left untouched. Snowflake variant access is unaffected (databricks-gated). Validated on the live E6 engine: the aliased form resolves the outer reference and returns rows; the unaliased form fails with "Column not found".
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 freeto 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.
Problem
A Databricks colon/variant projection written without an alias — e.g.
SELECT deep_dives:metrics_per_level— is implicitly named by Databricks after its final path segment (metrics_per_level). E6 has no such naming rule, so when an outer query references that column by name it fails:This is the "colon path stripped by transpiler" failure bucket.
Fix
For Databricks-sourced transpiles (
from_dialect="databricks"), make the implicit name explicit: a bare colon/variantJSONExtractappearing as a top-level SELECT projection is wrapped inAS <final-segment>.Scoped precisely by iterating the
Select's ownexpressions, so these are left untouched:WHERE/GROUP BY/ a function /CASE(not a top-level projection)… AS x)col:arr[0]— no implicit key name)Example
Validation
Column not found. Edge cases confirmed on the engine — reserved-word segment (box:limit→box:"limit" AS "limit") works; a duplicate final segment (a:x, b:x) reportsambiguous, which is faithful (Databricks also names both columnsx).tests/dialects/test_e6.py: existing top-level colon projections now carry their implicit alias, plus a new subquery-reference regression test. Full suite: 59 passed / 900 subtests.