Skip to content

Commit

Permalink
fix wrong type
Browse files Browse the repository at this point in the history
  • Loading branch information
syou6162 committed Jan 1, 2025
1 parent 7e9d187 commit 4ad33d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions dbterd/adapters/algos/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import copy
from typing import Dict, List
from typing import Dict, List, Tuple

import click

Expand Down Expand Up @@ -687,26 +687,26 @@ def get_table_map_from_metadata(test_node, **kwargs) -> List[str]:
return list(reversed(test_parents))


def get_table_map(test_node, **kwargs) -> List[str]:
def get_table_map(test_node, **kwargs) -> Tuple[str, str]:
"""Get the table map with order of [to, from] guaranteed
Args:
test_node (dict): Manifest Test node
Returns:
list: [to model, from model]
Tuple: (to model, from model)
"""
map = test_node.depends_on.nodes or []
map = tuple(test_node.depends_on.nodes) or ()

# Recursive relation case
# `from` and `to` will be identical and `test_node.depends_on.nodes` will contain only one element
if len(map) == 1:
return [map[0], map[0]]
return (map[0], map[0])

rule = get_algo_rule(**kwargs)
to_model = str(test_node.test_metadata.kwargs.get(rule.get("t_to", "to"), {}))
if f'("{map[1].split(".")[-1]}")'.lower() in to_model.replace("'", '"').lower():
return [map[1], map[0]]
return (map[1], map[0])

return map

Expand Down
16 changes: 8 additions & 8 deletions tests/unit/adapters/algos/test_test_relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,34 +119,34 @@ def test_get_compiled(self, manifest, expected):
[
Ref(
name="test.dbt_resto.relationships_table1",
table_map=["model.dbt_resto.table2", "model.dbt_resto.table1"],
table_map=("model.dbt_resto.table2", "model.dbt_resto.table1"),
column_map=["f2", "f1"],
),
Ref(
name="test.dbt_resto.relationships_table3",
table_map=["model.dbt_resto.tabley", "model.dbt_resto.tablex"],
table_map=("model.dbt_resto.tabley", "model.dbt_resto.tablex"),
column_map=["f2", "f1"],
),
Ref(
name="test.dbt_resto.relationships_table4",
table_map=[
table_map=(
"model.dbt_resto.table-m2",
"model.dbt_resto.table-m1",
],
),
column_map=["f2", "f1"],
type="11",
),
Ref(
name="test.dbt_resto.relationships_table1_reverse",
table_map=[
table_map=(
"model.dbt_resto.table-r2",
"model.dbt_resto.table-r1",
],
),
column_map=["f2", "f1"],
),
Ref(
name="test.dbt_resto.relationships_table1_recursive",
table_map=["model.dbt_resto.table1", "model.dbt_resto.table1"],
table_map=("model.dbt_resto.table1", "model.dbt_resto.table1"),
column_map=["f2", "f1"],
),
],
Expand All @@ -157,7 +157,7 @@ def test_get_compiled(self, manifest, expected):
[
Ref(
name="test.dbt_resto.foreign_key_table1",
table_map=["model.dbt_resto.table2", "model.dbt_resto.table1"],
table_map=("model.dbt_resto.table2", "model.dbt_resto.table1"),
column_map=["f2", "f1"],
),
],
Expand Down

0 comments on commit 4ad33d0

Please sign in to comment.