summaryrefslogtreecommitdiffstats
path: root/tests/test_lineage.py
blob: 7a48605ef28ac6ccba03c0404550dca9fcf471ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import unittest

from sqlglot.lineage import lineage


class TestLineage(unittest.TestCase):
    maxDiff = None

    def test_lineage(self) -> None:
        node = lineage(
            "a",
            "SELECT a FROM y",
            schema={"x": {"a": "int"}},
            sources={"y": "SELECT * FROM x"},
        )
        self.assertEqual(
            node.source.sql(),
            "SELECT y.a AS a FROM (SELECT x.a AS a FROM x AS x) AS y /* source: y */",
        )
        self.assertGreater(len(node.to_html()._repr_html_()), 1000)