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

CREATE SEQUENCE fails with cursor description #44

Open
tharwan opened this issue Feb 12, 2024 · 8 comments
Open

CREATE SEQUENCE fails with cursor description #44

tharwan opened this issue Feb 12, 2024 · 8 comments

Comments

@tharwan
Copy link
Contributor

tharwan commented Feb 12, 2024

from snowflake.sqlalchemy import URL
import sqlalchemy
import fakesnow

with fakesnow.patch():
    engine = sqlalchemy.create_engine(
        URL(
            account="abc123",
            user="testuser1",
            password="0123456",
            database="testdb",
            schema="public",
        )
    )

    with engine.connect() as con:
        print(con.execute("CREATE SEQUENCE insertion_id_seq START WITH 1").fetchall())

related to #40, the cursor description fails.

@tekumara
Copy link
Owner

The same approach to fix #40 should work here if you'd like to have a go?

@tharwan
Copy link
Contributor Author

tharwan commented Feb 12, 2024

yes! I will open a PR later today.

@tharwan
Copy link
Contributor Author

tharwan commented Feb 12, 2024

looking a little bit deeper it seems that sequences in general are not really working, because snowflake uses seq1.nextval but duckdb nextval(seq1). Which is also not supported currently in sqlglot. So I need another workaround for my tests anyway.

@tekumara
Copy link
Owner

Ah right.. so we probably also need a transformation from seq1.nextval -> nextval(seq1). fakesnow has a bunch of specialised transformations that live outside sqlglot.

@tharwan
Copy link
Contributor Author

tharwan commented Feb 13, 2024

The other problem is that in the case of create sequence, sqlglot does not recognize sequence as token, and therefore also not the rest of the command like the name.

@tekumara
Copy link
Owner

Ah right. I've found the sqlglot folks receptive to PRs that add more precise parsing.

@tekumara
Copy link
Owner

tekumara commented Mar 9, 2024

I've added support for parsing CREATE SEQUENCE to sqlglot here, if that helps?

@tharwan
Copy link
Contributor Author

tharwan commented Mar 9, 2024

Amazing, thanks!

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

2 participants