summaryrefslogtreecommitdiffstats
path: root/sqlglot/lineage.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sqlglot/lineage.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/sqlglot/lineage.py b/sqlglot/lineage.py
index bdd1d14..f10fbb9 100644
--- a/sqlglot/lineage.py
+++ b/sqlglot/lineage.py
@@ -153,7 +153,7 @@ def lineage(
raise ValueError(f"Could not find {column} in {scope.expression}")
for s in scope.union_scopes:
- to_node(index, scope=s, upstream=upstream)
+ to_node(index, scope=s, upstream=upstream, alias=alias)
return upstream
@@ -209,7 +209,11 @@ def lineage(
if isinstance(source, Scope):
# The table itself came from a more specific scope. Recurse into that one using the unaliased column name.
to_node(
- c.name, scope=source, scope_name=table, upstream=node, alias=aliases.get(table)
+ c.name,
+ scope=source,
+ scope_name=table,
+ upstream=node,
+ alias=aliases.get(table) or alias,
)
else:
# The source is not a scope - we've reached the end of the line. At this point, if a source is not found