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

fix(duckdb)!: Remove extra MAP bracket and ARRAY wrap #4712

Merged
merged 3 commits into from
Feb 11, 2025

Conversation

VaggelisD
Copy link
Collaborator

Fixes #4710

This PR solves two legacy issues:

  1. MAPs do not return LISTs anymore but values (1.2 change):
spark3> SELECT MAP('key', 'value')['key'] AS col;
col
value

# Transpilation before this PR
duckdb> SELECT (MAP(['key'], ['value'])['key'])[1] AS col;
┌─────────┐
│   col   │
│ varchar │
├─────────┤
│ v       │
└─────────┘

# Transpilation after this PR
duckdb> SELECT MAP(['key'], ['value'])['key'] AS col;
┌─────────┐
│   col   │
│ varchar │
├─────────┤
│ value   │
└─────────┘

  1. Inline indexed LISTs do not need to be wrapped anymore (this was fixed earlier in the year iirc):
spark-sql (default)> SELECT TRY_ELEMENT_AT(ARRAY(1, 2, 3), 2) AS col;
col
2

# Transpilation before this PR
duckdb> SELECT ([1, 2, 3])[2] AS col;
┌───────┐
│  col  │
│ int32 │
├───────┤
│   2   │
└───────┘

# Transpilation after this PR (used to error)
duckdb> SELECT [1, 2, 3][2] AS col;
┌───────┐
│  col  │
│ int32 │
├───────┤
│   2   │
└───────┘
  1. A silent T-SQL query turning into command due to typo

Docs

DuckDB 1.2

@tobymao
Copy link
Owner

tobymao commented Feb 6, 2025

you need to add a version to this, i think this is super breaking and breaks compatibility of sqlglot with older versions of duckdb

@georgesittas georgesittas requested a review from tobymao February 7, 2025 00:07
@georgesittas georgesittas merged commit 466c839 into main Feb 11, 2025
7 checks passed
@georgesittas georgesittas deleted the vaggelisd/ddb_compatibility branch February 11, 2025 10: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.

DuckDB 1.2.0 Compatbility
3 participants