From 261edfa78ab31c6a58499b30dc56d0548882d081 Mon Sep 17 00:00:00 2001 From: Aleksey Ovcharenko <938082+ovcharenko@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:48:27 +0300 Subject: [PATCH] [ADD] Support of `DROP VIEW` statements --- sqllineage/core/parser/sqlfluff/extractors/drop.py | 4 ++-- .../other_single_statement/test_other_without_lineage.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sqllineage/core/parser/sqlfluff/extractors/drop.py b/sqllineage/core/parser/sqlfluff/extractors/drop.py index a254b52e..541b4165 100644 --- a/sqllineage/core/parser/sqlfluff/extractors/drop.py +++ b/sqllineage/core/parser/sqlfluff/extractors/drop.py @@ -11,7 +11,7 @@ class DropExtractor(BaseExtractor): Drop statement lineage extractor """ - SUPPORTED_STMT_TYPES = ["drop_table_statement"] + SUPPORTED_STMT_TYPES = ["drop_table_statement", "drop_view_statement"] def extract( self, @@ -23,7 +23,7 @@ def extract( for segment in list_child_segments(statement): if ( segment.type == "keyword" - and segment.raw_upper == "TABLE" + and segment.raw_upper in ["TABLE", "VIEW"] or (drop_flag is True and segment.raw_upper in ["IF", "EXISTS"]) ): drop_flag = True diff --git a/tests/sql/table/other_single_statement/test_other_without_lineage.py b/tests/sql/table/other_single_statement/test_other_without_lineage.py index ae91b167..4e746eed 100644 --- a/tests/sql/table/other_single_statement/test_other_without_lineage.py +++ b/tests/sql/table/other_single_statement/test_other_without_lineage.py @@ -16,6 +16,10 @@ def test_drop_with_comment(): ) +def test_drop_view(): + assert_table_lineage_equal("DROP VIEW IF EXISTS view1") + + def test_alter_table_rename(): assert_table_lineage_equal("ALTER TABLE tab1 rename TO tab2")