Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingest/tableau): Fix TableauUpstream create check #12320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading