CREATE SEQUENCE fails with cursor description
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.
The same approach to fix #40 should work here if you'd like to have a go?
yes! I will open a PR later today.
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.
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.
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.
Ah right. I've found the sqlglot folks receptive to PRs that add more precise parsing.
I've added support for parsing CREATE SEQUENCE to sqlglot here, if that helps?
Amazing, thanks!