Skip to content

Commit

Permalink
fix: source table name and select statement both in parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
reata committed Mar 13, 2022
1 parent 57a3b64 commit 3a8db5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sqllineage/utils/sqlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def is_subquery(token: TokenList) -> bool:
if isinstance(token, Parenthesis):
# in case of subquery in nested parenthesis, find the innermost one first
while True:
_, sub_paren = token.token_next_by(i=Parenthesis)
if sub_paren is not None:
idx, sub_paren = token.token_next_by(i=Parenthesis)
if sub_paren is not None and idx == 1:
token = sub_paren
else:
break
Expand Down
6 changes: 6 additions & 0 deletions tests/test_others.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ def test_create_as_with_parenthesis_around_table_name():
)


def test_create_as_with_parenthesis_around_both():
assert_table_lineage_equal(
"CREATE TABLE tab1 AS (SELECT * FROM (tab2))", {"tab2"}, {"tab1"}
)


def test_create_like():
assert_table_lineage_equal("CREATE TABLE tab1 LIKE tab2", {"tab2"}, {"tab1"})

Expand Down

0 comments on commit 3a8db5d

Please sign in to comment.