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

DELETE statement fails with Parser Error #40

Closed
tharwan opened this issue Feb 6, 2024 · 2 comments · Fixed by #41
Closed

DELETE statement fails with Parser Error #40

tharwan opened this issue Feb 6, 2024 · 2 comments · Fixed by #41

Comments

@tharwan
Copy link
Contributor

tharwan commented Feb 6, 2024

Hi I triggered another issue when issuing a DELETE:

from snowflake.sqlalchemy import URL
import sqlalchemy
import fakesnow
from sqlalchemy.ext.declarative import declarative_base

from sqlalchemy import Column, Integer

Base = declarative_base()


class TestTable(Base):
    __tablename__ = "testtable"
    id_col = Column(Integer, primary_key=True, autoincrement=False)
    val_col = Column(Integer)


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

    TestTable.__table__.create(engine)

    with engine.connect() as con:
        ins = TestTable.__table__.insert().values(id_col=1, val_col=10)
        con.execute(ins)
        ins = TestTable.__table__.insert().values(id_col=2, val_col=20)
        con.execute(ins)

        con.execute("CREATE TABLE TESTTABLE2 AS FROM TESTTABLE")

        print(con.execute("SELECT * FROM TESTTABLE").fetchall())
        print(con.execute("SELECT * FROM TESTTABLE2").fetchall())

        print(
            con.execute(
                "DELETE FROM TESTTABLE2 USING TESTTABLE WHERE TESTTABLE.id_col = TESTTABLE2.id_col"
            ).fetchall()
        )

Results in:

duckdb.duckdb.ParserException: Parser Error: syntax error at or near "FROM"
LINE 1: DESCRIBE DELETE FROM TESTTABLE2 USING TESTTABLE WHERE T...

This looks related to #38 for me as it also happens in the describe.

@tharwan tharwan changed the title DELETE statement fails with sqlglot.errors.ParseError DELETE statement fails with Parser Error Feb 6, 2024
@tharwan
Copy link
Contributor Author

tharwan commented Feb 7, 2024

@tekumara any hints how I could maybe contribute here with a PR? Where should the logic go to exclude deletes from being "described"?

@tekumara
Copy link
Owner

tekumara commented Feb 8, 2024

That would be great if you want to have a go. We'd need something very similar to f1187b1, including a minimal test case that mirrors what Snowflake returns for a description.

tekumara added a commit that referenced this issue Feb 9, 2024
fixes #40

---------

Co-authored-by: fkuehnlenz <florian.kuehnlenz@e2m.energy>
Co-authored-by: Oliver Mannion <125105+tekumara@users.noreply.github.com>
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

Successfully merging a pull request may close this issue.

2 participants