summaryrefslogtreecommitdiffstats
path: root/tests/test_lineage.py
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2023-12-10 10:45:55 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2023-12-10 10:45:55 +0000
commit02df6cdb000c8dbf739abda2af321a4f90d1b059 (patch)
tree2fc1daf848082ff67a11e60025cac260e3c318b2 /tests/test_lineage.py
parentAdding upstream version 19.0.1. (diff)
downloadsqlglot-02df6cdb000c8dbf739abda2af321a4f90d1b059.tar.xz
sqlglot-02df6cdb000c8dbf739abda2af321a4f90d1b059.zip
Adding upstream version 20.1.0.upstream/20.1.0
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'tests/test_lineage.py')
-rw-r--r--tests/test_lineage.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_lineage.py b/tests/test_lineage.py
index 25329e2..8755b42 100644
--- a/tests/test_lineage.py
+++ b/tests/test_lineage.py
@@ -229,13 +229,36 @@ class TestLineage(unittest.TestCase):
"output",
"SELECT (SELECT max(t3.my_column) my_column FROM foo t3) AS output FROM table3",
)
- self.assertEqual(node.name, "SUBQUERY")
+ self.assertEqual(node.name, "output")
node = node.downstream[0]
self.assertEqual(node.name, "my_column")
node = node.downstream[0]
self.assertEqual(node.name, "t3.my_column")
self.assertEqual(node.source.sql(), "foo AS t3")
+ node = lineage(
+ "y",
+ "SELECT SUM((SELECT max(a) a from x) + (SELECT min(b) b from x) + c) AS y FROM x",
+ )
+ self.assertEqual(node.name, "y")
+ self.assertEqual(len(node.downstream), 3)
+ self.assertEqual(node.downstream[0].name, "a")
+ self.assertEqual(node.downstream[1].name, "b")
+ self.assertEqual(node.downstream[2].name, "x.c")
+
+ node = lineage(
+ "x",
+ "WITH cte AS (SELECT a, b FROM z) SELECT sum(SELECT a FROM cte) AS x, (SELECT b FROM cte) as y FROM cte",
+ )
+ self.assertEqual(node.name, "x")
+ self.assertEqual(len(node.downstream), 1)
+ node = node.downstream[0]
+ self.assertEqual(node.name, "a")
+ node = node.downstream[0]
+ self.assertEqual(node.name, "cte.a")
+ node = node.downstream[0]
+ self.assertEqual(node.name, "z.a")
+
def test_lineage_cte_union(self) -> None:
query = """
WITH dataset AS (