Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lateral flatten index unsupported #143

Closed
rogalski opened this issue Oct 14, 2024 · 0 comments · Fixed by #138
Closed

Lateral flatten index unsupported #143

rogalski opened this issue Oct 14, 2024 · 0 comments · Fixed by #138

Comments

@rogalski
Copy link

SQL:

select id, f.value::varchar as v, f.index as i
from (select column1 as id, column2 as col from (values (1, 's1,s2,s3'), (2, 's1,s2'))) as t
, lateral flatten(input => split(t.col, ',')) as f order by id;

Rewritten SQL:

SELECT ID, F.VALUE ->> '$' AS V, F.INDEX AS I FROM (SELECT COLUMN1 AS ID, COLUMN2 AS COL FROM (VALUES (1, 's1,s2,s3'), (2, 's1,s2')) AS _("COLUMN1", "COLUMN2")) AS T, LATERAL UNNEST(CAST(TO_JSON(STR_SPLIT(T.COL, ',')) AS JSON[])) AS F(VALUE) ORDER BY ID;

Error:

snowflake.connector.errors.ProgrammingError: 002043 (02000): None: Binder Error: Table "F" does not have a column named "INDEX"

Version: main

DuckDB docs recommends extra SELECT with generate_subscripts: https://duckdb.org/docs/sql/query_syntax/unnest.html#keeping-track-of-list-entry-positions

tekumara pushed a commit that referenced this issue Nov 9, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.9.26](v0.9.25...v0.9.26)
(2024-11-09)


### Features

* flatten returns an index column
([f603d0c](f603d0c)),
closes [#143](#143)
* Support TRUNCATE TABLE description
([#144](#144))
([234bbaf](234bbaf))


### Chores

* bump sqlglot 25.22.0
([3c1f244](3c1f244))
* cruft update
([5d09f8b](5d09f8b))
* **deps-dev:** bump pyright from 1.1.378 to 1.1.382
([#142](#142))
([a3898ce](a3898ce))
* **deps-dev:** bump pyright from 1.1.382 to 1.1.387
([#145](#145))
([d6058d7](d6058d7))
* **deps:** update duckdb requirement from ~=1.0.0 to ~=1.1.3
([#150](#150))
([ecd4d46](ecd4d46))
* **deps:** update pre-commit requirement from ~=3.4 to ~=4.0
([#147](#147))
([5a1f866](5a1f866))
* **deps:** update ruff requirement from ~=0.6.3 to ~=0.7.2
([#146](#146))
([e9ae13a](e9ae13a))
* **deps:** update snowflake-sqlalchemy requirement from ~=1.5.0 to
~=1.6.1 ([#119](#119))
([89a315a](89a315a))
* **deps:** update sqlglot requirement from ~=25.22.0 to ~=25.24.1
([#141](#141))
([8e7c343](8e7c343))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: potatobot-prime[bot] <132267321+potatobot-prime[bot]@users.noreply.github.com>
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 a pull request may close this issue.

1 participant