-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathtest_lineage.py
More file actions
40 lines (31 loc) · 1.18 KB
/
test_lineage.py
File metadata and controls
40 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from sqlmesh.core import dialect as d
from sqlmesh.core.config import Config
from sqlmesh.core.config.model import ModelDefaultsConfig
from sqlmesh.core.context import Context
from sqlmesh.core.lineage import column_dependencies, column_description, lineage
from sqlmesh.core.model import load_sql_based_model
def test_column_dependencies(sushi_context_pre_scheduling):
context = sushi_context_pre_scheduling
assert column_dependencies(context, "sushi.waiter_revenue_by_day", "revenue") == {
'"memory"."sushi"."items"': {"price"},
'"memory"."sushi"."order_items"': {"quantity"},
}
def test_column_description(sushi_context_pre_scheduling):
context = sushi_context_pre_scheduling
assert column_description(context, "sushi.top_waiters", "waiter_id") == "Waiter id"
def test_lineage():
context = Context(config=Config(model_defaults=ModelDefaultsConfig(dialect="snowflake")))
model = load_sql_based_model(
d.parse(
"""
MODEL (name db.model1);
SELECT "A"
FROM (
SELECT 1 a
) x
"""
),
)
context.upsert_model(model)
node = lineage('"A"', model)
assert node.name == "A"