reata / sqllineage

SQL Lineage Analysis Tool powered by Python
MIT License
1.3k stars 235 forks source link

The second and subsequent case when subqueries in the select_clause are not correctly recognized #559

Closed maoxingda closed 8 months ago

maoxingda commented 8 months ago

SQL

select
    1,
    case
        when 1 = ( select count(*) from tab1 where col1 = 'tab2' )
            then ( select count(*) from tab2 )
        else 0
    end as cnt

To Reproduce

Note here we refer to SQL provided in prior step as stored in a file named test.sql

from sqllineage.runner import LineageRunner

with open("test.sql") as f:
    sql = f.read()

lr = LineageRunner(sql, dialect="redshift")

print(lr.source_tables)

Actual behavior

[]

Expected behavior

[Table: <default>.tab1, Table: <default>.tab2]

Python version (available via python --version)

SQLLineage version (available via sqllineage --version):

Additional context