Skip to content

Commit

Permalink
Fix TableaUpstream create
Browse files Browse the repository at this point in the history
  • Loading branch information
treff7es committed Jan 10, 2025
1 parent b86bbf7 commit cb1bb11
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,7 @@ def emit_upstream_tables(self) -> Iterable[MetadataWorkUnit]:
c.ID_WITH_IN: list(tableau_database_table_id_to_urn_map.keys())
}

# Emmitting tables that came from Tableau metadata
# Emitting tables that came from Tableau metadata
for tableau_table in self.get_connection_objects(
database_tables_graphql_query,
c.DATABASE_TABLES_CONNECTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,11 @@ class TableauUpstreamReference:

@classmethod
def create(
cls, d: dict, default_schema_map: Optional[Dict[str, str]] = None
cls, d: Dict, default_schema_map: Optional[Dict[str, str]] = None
) -> "TableauUpstreamReference":
if d is None:
raise ValueError("TableauUpstreamReference.create: d is None")

# Values directly from `table` object from Tableau
database_dict = (
d.get(c.DATABASE) or {}
Expand Down Expand Up @@ -717,7 +720,7 @@ def parse_full_name(full_name: Optional[str]) -> Optional[List[str]]:
# schema

# TODO: Validate the startswith check. Currently required for our integration tests
if full_name is None or not full_name.startswith("["):
if full_name is None:
return None

return full_name.replace("[", "").replace("]", "").split(".")
Expand Down
21 changes: 21 additions & 0 deletions metadata-ingestion/tests/unit/test_tableau_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import datahub.ingestion.source.tableau.tableau_constant as c
from datahub.ingestion.source.tableau.tableau import TableauSiteSource
from datahub.ingestion.source.tableau.tableau_common import (
TableauUpstreamReference,
get_filter_pages,
make_filter,
optimize_query_filter,
Expand Down Expand Up @@ -247,3 +248,23 @@ def test_optimize_query_filter_handles_no_duplicates():
assert len(result) == 2
assert result[c.ID_WITH_IN] == ["id1", "id2"]
assert result[c.PROJECT_NAME_WITH_IN] == ["project1", "project2"]


def testTableaUpstreamReference():
d = {
"id": "7127b695-3df5-4a3a-4837-eb0f4b572337",
"name": "TABLE1",
"database": None,
"schema": "SCHEMA1",
"fullName": "DB1.SCHEMA1.TABLE1",
"connectionType": "snowflake",
"description": "",
"columnsConnection": {"totalCount": 0},
}
ref = TableauUpstreamReference.create(d)
assert ref

assert ref.database == "DB1"
assert ref.schema == "SCHEMA1"
assert ref.table == "TABLE1"
assert ref.connection_type == "snowflake"

0 comments on commit cb1bb11

Please sign in to comment.