@@ -22,11 +22,12 @@ def extract_non_selected_columns(parsed: exp.Select) -> list[Column]:
22
22
table_alias = {}
23
23
for table in tables :
24
24
if table .alias :
25
- table_alias [table .alias ] = table . name
25
+ table_alias [table .alias ] = merge_parts ( table )
26
26
27
27
table_names = {}
28
28
for table in tables :
29
- table_names [table .name ] = table
29
+ table_key = merge_parts (table )
30
+ table_names [table_key ] = table
30
31
31
32
for scopes in [where , join , group ]:
32
33
for scope in scopes :
@@ -133,9 +134,13 @@ def get_column_lineage(query: str, schema: dict, dialect: str):
133
134
):
134
135
continue
135
136
136
- cl .append (
137
- {"column" : ds .name .split ("." )[- 1 ], "table" : ds .expression .this .name }
138
- )
137
+ if isinstance (ds .expression , exp .Table ):
138
+ cl .append (
139
+ {
140
+ "column" : ds .name .split ("." )[- 1 ],
141
+ "table" : merge_parts (ds .expression ),
142
+ }
143
+ )
139
144
140
145
# Deduplicate based on column-table combination
141
146
cl = [dict (t ) for t in {tuple (d .items ()) for d in cl }]
@@ -169,3 +174,7 @@ def find_leaf_nodes(node: Node, leaf_nodes):
169
174
else :
170
175
for child in node .downstream :
171
176
find_leaf_nodes (child , leaf_nodes )
177
+
178
+
179
+ def merge_parts (table : exp .Table ) -> str :
180
+ return "." .join (part .name for part in table .parts if isinstance (part , exp .Identifier ))
0 commit comments