tobymao / sqlglot

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

Parser not bubbling obvious syntax error #4303

Closed cploonker closed 2 hours ago

cploonker commented 2 hours ago

Before you file an issue

>>> import sqlglot
>>> sqlglot.parse_one("select ,a ,b from tbl")
Select(
  expressions=[
    Column(
      this=Identifier(this=a, quoted=False)),
    Column(
      this=Identifier(this=b, quoted=False))],
  from=From(
    this=Table(
      this=Identifier(this=tbl, quoted=False))))

Official Documentation Please include links to official SQL documentation related to your issue.

tobymao commented 2 hours ago

there generated query shouldn’t fail. can you validate that?

sqlglot is not a validator. but it tries to generate valid sql

cploonker commented 1 hour ago

@tobymao you are right. The generated query from sqlglot does not fail. But the original query does. I thought if there was a STRICT mode for the parser which will throw error then i could have used it. But i understand.

BTW I am a huge fan of Sqlglot. There is no equivalent for it. And we can achieve some seemingly impossible sql manipulation using Sqlglot. It is just pure magic.