Describe the bug
Relations are wrong when using intermediate tables on column level. When using a intermediate table and naming its columns, it is describing the columns as the Table/Subquery instead of the table name specified.
SQL
insert into db_test.table_target
select col_1_renamed, col_2_renamed from
(Select col1, max(col2) from db_test.table_src
where
col1 = "AV" and
col2 is not null
) AS Inter_table(col_1_renamed, col_2_renamed);
To Reproduce
from sqllineage.runner import LineageRunner, LineageLevel
query = """ insert into db_test.table_target
select col_1_renamed, col_2_renamed from
(Select col1, max(col2) from db_test.table_src
where
col1 = "AV" and
col2 is not null
) AS Inter_table(col_1_renamed, col_2_renamed);
"""
result = (
LineageRunner(query, dialect="teradata")
)
lineage_stmt = result.to_cytoscape(LineageLevel.COLUMN)
print(lineage_stmt)
Expected behavior
The code should detect Inter_table as the Subquery and not (col_1_renamed, col_2_renamed) as a whole. The column lineage as source and target should be:
db_test.table_src.col1 -> Inter_table.col_1_renamed
db_test.table_src.col2 -> Inter_table.col_2_renamed
Describe the bug Relations are wrong when using intermediate tables on column level. When using a intermediate table and naming its columns, it is describing the columns as the Table/Subquery instead of the table name specified.
SQL
To Reproduce
Expected behavior The code should detect Inter_table as the Subquery and not (col_1_renamed, col_2_renamed) as a whole. The column lineage as source and target should be: db_test.table_src.col1 -> Inter_table.col_1_renamed db_test.table_src.col2 -> Inter_table.col_2_renamed
Inter_table.col_1_renamed -> db_test.table_target.col_1_renamed Inter_table.col_2_renamed -> db_test.table_target.col_2_renamed
**Python version
SQLLineage version (available via
sqllineage --version
):Additional context Looks like there is a problem when detecting intermediate tables