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

Feat(duckdb): add support for simplified pivot syntax #1714

Merged
merged 6 commits into from
Jun 1, 2023

Conversation

georgesittas
Copy link
Collaborator

@georgesittas georgesittas commented Jun 1, 2023

Fixes #1712

Also added support for the standalone FROM tbl expression (see example below) which is used in DuckDB's pivot examples. This is essentially a shorthand for SELECT * FROM tbl and it seems useful to support in the base parser. We could also improve the from_ helper to allow from_(..., star=True) as a way to dry up exp.select("*").from_(...). @tobymao thoughts on this?

>>> import duckdb
>>> duckdb.connect().execute("with t as (select 1) select * from (from t)").fetchdf()
   1
0  1
>>> duckdb.connect().execute("with t as (select 1) from (from t)").fetchdf()
   1
0  1

References:

sqlglot/parser.py Outdated Show resolved Hide resolved
sqlglot/parser.py Outdated Show resolved Hide resolved
@georgesittas georgesittas merged commit 17dc0e1 into main Jun 1, 2023
@georgesittas georgesittas deleted the jo/duckdb_pivots branch June 1, 2023 19:48
adrianisk pushed a commit to adrianisk/sqlglot that referenced this pull request Jun 21, 2023
* Feat(duckdb): add support for simplified pivot syntax

* Fixups

* Fixups

* Cleanup

* Use explicit kwarg name

* Fixup
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.

PIVOT clause in duckdb==0.8.0 results in ParseError
2 participants