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

Support for duckdb's fancy Syntaxes #2118

Closed
aersam opened this issue Aug 28, 2023 · 0 comments
Closed

Support for duckdb's fancy Syntaxes #2118

aersam opened this issue Aug 28, 2023 · 0 comments

Comments

@aersam
Copy link
Contributor

aersam commented Aug 28, 2023

DuckDB supports a number of interesting features, not all are supported yet.
See https://duckdb.org/2023/08/23/even-friendlier-sql.html

Here's what's not supported:

FROM first

import sqlglot

sql = """FROM my_table SELECT my_column"""
sqlglot.parse_one(sql, read="duckdb")

Union BY NAME

import sqlglot
sql = """ SELECT 
          'Revenge is a dish best served cold' AS klingon_proverb 
     UNION ALL BY NAME 
     SELECT 
          'You will be assimilated' AS borg_proverb,
          'If winning is not important, why keep score?' AS klingon_proverb"""
sqlglot.parse_one(sql, read="duckdb")

Insert By Name

import sqlglot

sql = """INSERT INTO proverbs BY NAME 
     SELECT 'Resistance is futile' AS borg_proverb"""
sqlglot.parse_one(sql, read="duckdb")

List Comprehensions

import sqlglot

sql = """SELECT 
     [x.string_split(' ')[1] 
     FOR x IN ['Enterprise NCC-1701', 'Voyager NCC-74656', 'Discovery NCC-1031'] 
     IF x.contains('1701')] AS ready_to_boldly_go"""
sqlglot.parse_one(sql, read="duckdb")

That's it I think. In general I was surprised how much is already supported by sqlglot, thanks a lot for this!

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

No branches or pull requests

1 participant