sqlglot - Why is not able to parse correctly DELETE SQL Statement?

Viewed 102

Why Python module sqlglot is not able to parse correctly DELETE SQL Statement?

import sqlglot

sql="DELETE FROM MySchema.MyTable WHERE MyCol='MyValue'"

parsed=sqlglot.parse_one(sql)

Result:

parsed

(COMMAND this: DELETE, expression:
  (LITERAL this:  FROM MySchema.MyTable WHERE MyCol='MyValue', is_string: True))

Why sqlglot is capable of parsing the other DML commands (SELECT, INSERT, UPDATE) but not DELETE?

Am I doing something wrong?

Thanks.

1 Answers

DELETE parsing is only partially supported as of v1.24.2. We interpret it as a command and parse the rest. I haven't really had a need to parse DELETE and so support is not fully functional.

EDIT: As of v1.24.3, SQLGlot now supporst DELETE FROM

(DELETE this:
  (TABLE this:
    (IDENTIFIER this: MyTable, quoted: False), db:
    (IDENTIFIER this: MySchema, quoted: False)), where:
  (WHERE this:
    (EQ this:
      (COLUMN this:
        (IDENTIFIER this: MyCol, quoted: False)), expression:
      (LITERAL this: MyValue, is_string: True))))
Related