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

InvalidSyntaxException When SQL Statement Ends with Multiple Semicolons #502

Closed
reata opened this issue Dec 11, 2023 · 0 comments · Fixed by #503
Closed

InvalidSyntaxException When SQL Statement Ends with Multiple Semicolons #502

reata opened this issue Dec 11, 2023 · 0 comments · Fixed by #503
Labels
bug Something isn't working

Comments

@reata
Copy link
Owner

reata commented Dec 11, 2023

Describe the bug
When a SQL statement ends with multiple semicolons, it will be split to several statements with all of them other than the first one contain a semicolon only. And those semicolon only statement triggers InvalidSyntaxException

SQL
Paste the SQL text here. For example:

SELECT * FROM DUAL;;

To Reproduce

sqllineage -f test.sql --dialect=ansi
Traceback (most recent call last):
  File "/home/hujunwei/.pyenv/versions/3.12.0/bin/sqllineage", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/hujunwei/.pyenv/versions/3.12.0/lib/python3.12/site-packages/sqllineage/cli.py", line 109, in main
    runner.print_table_lineage()
  File "/home/hujunwei/.pyenv/versions/3.12.0/lib/python3.12/site-packages/sqllineage/runner.py", line 176, in print_table_lineage
    print(str(self))
          ^^^^^^^^^
  File "/home/hujunwei/.pyenv/versions/3.12.0/lib/python3.12/site-packages/sqllineage/runner.py", line 26, in wrapper
    self._eval()
  File "/home/hujunwei/.pyenv/versions/3.12.0/lib/python3.12/site-packages/sqllineage/runner.py", line 193, in _eval
    self._stmt_holders = [analyzer.analyze(stmt) for stmt in self._stmt]
                          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hujunwei/.pyenv/versions/3.12.0/lib/python3.12/site-packages/sqllineage/core/parser/sqlfluff/analyzer.py", line 42, in analyze
    statement_segments = self._list_specific_statement_segment(sql)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hujunwei/.pyenv/versions/3.12.0/lib/python3.12/site-packages/sqllineage/core/parser/sqlfluff/analyzer.py", line 73, in _list_specific_statement_segment
    raise InvalidSyntaxException(
sqllineage.exceptions.InvalidSyntaxException: This SQL statement is unparsable, please check potential syntax error for SQL:
;
Line 1, Position 1: Found unparsable section: ';'

Expected behavior
No exception thrown.

Python version (available via python --version)

  • 3.12.0

SQLLineage version (available via sqllineage --version):

  • 1.4.9
@reata reata added the bug Something isn't working label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant