-
|
I want to get all errors when I have multiple semicolon separated statements. This is what I have come up with, but it does not look intuitive. Is there a better way to create my own Parser instance, so I can access parser.errors? import sqlglot # 13.3.1.dev1
from sqlglot.errors import ErrorLevel
from sqlglot import Dialect, Parser
sql = """
SELECT . FROM t;
SELECT . FROM t;
SELECT * FROM .;
""".strip()
dia = Dialect()
p : Parser = dia.parser(error_level=ErrorLevel.IGNORE)
res = p.parse(dia.tokenize(sql), sql)
for e in p.errors:
print(e.errors)Output: By the way, there seems to be a one-off issue with the first error: notice the |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
|
This looks fine to me. |
Beta Was this translation helpful? Give feedback.
-
|
@tobymao thanks for the answer. And what about the one-off column index? Should I create an issue for that? Note that when I change the sql to -- comment
SELECT . FROM t;
SELECT . FROM t;
SELECT * FROM .;Then the output is: As you can see, then it's |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Colon 8 should be into desired expression |
Beta Was this translation helpful? Give feedback.
This looks fine to me.