From 38e6461a8afbd7cb83709ddb998f03d40ba87755 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 23 Jan 2024 06:06:14 +0100 Subject: Merging upstream version 20.9.0. Signed-off-by: Daniel Baumann --- sqlglot/lineage.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sqlglot/lineage.py') diff --git a/sqlglot/lineage.py b/sqlglot/lineage.py index abcc10f..09bf201 100644 --- a/sqlglot/lineage.py +++ b/sqlglot/lineage.py @@ -129,13 +129,10 @@ def lineage( if isinstance(column, int) else next( (select for select in scope.expression.selects if select.alias_or_name == column), - exp.Star() if scope.expression.is_star else None, + exp.Star() if scope.expression.is_star else scope.expression, ) ) - if not select: - raise ValueError(f"Could not find {column} in {scope.expression}") - if isinstance(scope.expression, exp.Union): upstream = upstream or Node(name="UNION", source=scope.expression, expression=select) @@ -194,6 +191,8 @@ def lineage( # if the select is a star add all scope sources as downstreams if select.is_star: for source in scope.sources.values(): + if isinstance(source, Scope): + source = source.expression node.downstream.append(Node(name=select.sql(), source=source, expression=source)) # Find all columns that went into creating this one to list their lineage nodes. -- cgit v1.2.3