tobymao / sqlglot

Python SQL Parser and Transpiler
https://sqlglot.com/
MIT License
6.74k stars 706 forks source link

[duckdb] `CREATE SECRET` #4404

Closed kfollesdal closed 4 hours ago

kfollesdal commented 4 hours ago

While using sqlmesh with duckdb, and are using the secret manager in duckdb to authenticate connection to azure storage account.

I discovered that sqlglot do not support CREATE SECRET ..., I get a WARING, but sqlmesh run fine. So this is not critical, so just nice to fix.

With sqlglot from main commit 647b98d

sqlglot.parse_one("""
    CREATE SECRET azure_secret (
        TYPE AZURE,
        PROVIDER CREDENTIAL_CHAIN,
        CHAIN 'cli',
        ACCOUNT_NAME 'mystorage'
    );
""",
read="duckdb")

gives

'CREATE SECRET azure_secret (
        TYPE AZURE,
        PROVIDER CREDENTIAL_CHAIN,
        CHAIN 'c' contains unsupported syntax. Falling back to parsing as a 'Command'.
Command(this=CREATE, expression=SECRET azure_secret (
           TYPE AZURE,
           PROVIDER CREDENTIAL_CHAIN,
           CHAIN 'cli',
           ACCOUNT_NAME 'mystorage'
       ))

Is this something that is easily fixed? Maybe point me to the right place in code with description on what must be done and I can try to make a PR.

georgesittas commented 4 hours ago

You'd need to:

georgesittas commented 4 hours ago

This is relatively low priority for the core team, but we'll be happy to accept a well-crafted PR for this. Feel free to reach out in Slack if you need further guidance.