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

Feature Request: Support for Duckdb #730

Open
PMassicotte opened this issue Apr 12, 2024 · 4 comments
Open

Feature Request: Support for Duckdb #730

PMassicotte opened this issue Apr 12, 2024 · 4 comments

Comments

@PMassicotte
Copy link

duckdb is getting a lot of attention as a fast in-process analytical database. I found out that duckdb is not currently supported. I am currently using spark option, but it is not working every time.

Are there any plans to add it?

@nene
Copy link
Collaborator

nene commented Apr 13, 2024

Thanks for the feature request.

I'm open for a pull request, but I'm not really interested in implementing it by myself. Luckily for you, adding a support for a new dialect to sql-formatter is not that hard. You don't even need to fork sql-formatter to do so, you can just provide it a custom dialect definition.

Well, admittedly there's not that much of documentation there, but just copying an existing dialect implementation from sql-formatter source code and modifying it slightly should be pretty simple.

You can also look at the wiki, which documents syntax details of all the currently supported SQL dialects.

@PMassicotte
Copy link
Author

Great, I will have a look at it!

@PMassicotte
Copy link
Author

Just for reference:

select * from duckdb_keywords();
select * from duckdb_functions();

@hughcameron
Copy link

I've set up a PR for this.

It's based on the duckdb words:

COPY (
    SELECT DISTINCT upper(function_name) AS function_name
    FROM duckdb_functions()
    WHERE function_name SIMILAR TO '^[a-z].*'
    ORDER BY function_name
) TO 'duckdb_functions.txt' WITH (sep ',', header FALSE);


COPY (
    SELECT upper(keyword_name)
    FROM duckdb_keywords()
    ORDER BY keyword_name
) TO 'duckdb_keywords.txt' WITH (sep ',', header FALSE);


COPY (
    SELECT DISTINCT upper(logical_type)
    FROM duckdb_types()
    ORDER BY logical_type
) TO 'duckdb_types.txt' WITH (sep ',', header FALSE);

I've also leveraged the postgres tests, most are passing. I'm not clear on how to resolve the failing tests - it would be great to get some help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants