Skip to content

clickhouse <rename> not handled #642

@maciejskorski

Description

@maciejskorski

Describe the bug

Consider this SQL in ClickHouse dialect

-- query.txt
RENAME TABLE my_db.app_log_trivial  TO my_db.app_log_trivial_tmp_old;
RENAME TABLE  my_db.app_log_trivial_tmp TO my_db.app_log_trivial;
DROP TABLE my_db.app_log_trivial_tmp_old;

linted with sqllineage 1.5.3 it gives the error

sqllineage -f query.txt -v
Traceback (most recent call last):
  File "/usr/local/bin/sqllineage", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/sqllineage/cli.py", line 127, in main
    runner.print_table_lineage()
  File "/usr/local/lib/python3.10/dist-packages/sqllineage/runner.py", line 179, in print_table_lineage
    print(str(self))
  File "/usr/local/lib/python3.10/dist-packages/sqllineage/runner.py", line 26, in wrapper
    self._eval()
  File "/usr/local/lib/python3.10/dist-packages/sqllineage/runner.py", line 199, in _eval
    stmt_holder = analyzer.analyze(stmt, session.metadata_provider)
  File "/usr/local/lib/python3.10/dist-packages/sqllineage/core/parser/sqlfluff/analyzer.py", line 52, in analyze
    statement_segments = self._list_specific_statement_segment(sql)
  File "/usr/local/lib/python3.10/dist-packages/sqllineage/core/parser/sqlfluff/analyzer.py", line 92, in _list_specific_statement_segment
    raise InvalidSyntaxException(
sqllineage.exceptions.InvalidSyntaxException: This SQL statement is unparsable, please check potential syntax error for SQL:
RENAME TABLE my_db.app_log_trivial  TO my_db.app_log_trivial_tmp_old;
Line 1, Position 1: Found unparsable section: 'RENAME TABLE my_db.app_log_trivial  TO m...'

indicating that sqllineage does not understand RENAME operator.

Furthermore, the check against the backend linter sqlfluff goes OK.

Expected behavior

RENAME is understood and handled correctly.

Python version (available via python --version)

  • 3.10.12

SQLLineage version (available via sqllineage --version):

  • 1.5.3

Additional context
Reproduced in Colab

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions