Fixed Tableau-Bigquery lineage issue (#12570)

This commit is contained in:
Onkar Ravgan 2023-07-26 16:07:48 +05:30 committed by GitHub
parent 30cdc840ab
commit 0f8ebf4afe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 1 deletions

View File

@ -45,6 +45,12 @@ class TableauOwnersNotFound(Exception):
"""
class TableauDataModelsException(Exception):
"""
Raise when Data Source information is not retrieved from the Tableau Graphql Query
"""
class TableauClient:
"""
Wrapper to TableauServerConnection
@ -116,6 +122,21 @@ class TableauClient:
)
]
def test_get_datamodels(self):
"""
Method to test the datamodels
"""
data = self._query_datasources(entities_per_page=1, offset=0)
if data:
return data
raise TableauDataModelsException(
"Unable to fetch Data Sources from tableau\n"
"Please check if the Tableau Metadata APIs are enabled for you Tableau instance\n"
"For more information on enabling the Tableau Metadata APIs follow the link below\n"
"https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_start.html"
"#enable-the-tableau-metadata-api-for-tableau-server\n"
)
def _query_datasources(
self, entities_per_page: int, offset: int
) -> Optional[TableauDatasources]:

View File

@ -89,6 +89,7 @@ def test_connection(
parameter_dict=TABLEAU_GET_VIEWS_PARAM_DICT,
),
"GetOwners": client.get_owners,
"GetDataModels": client.test_get_datamodels,
}
test_connection_steps(

View File

@ -29,6 +29,9 @@ from metadata.generated.schema.entity.data.table import Column, DataType, Table
from metadata.generated.schema.entity.services.connections.dashboard.tableauConnection import (
TableauConnection,
)
from metadata.generated.schema.entity.services.connections.database.bigQueryConnection import (
BigQueryConnection,
)
from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import (
OpenMetadataConnection,
)
@ -367,6 +370,8 @@ class TableauSource(DashboardServiceSource):
if table.database and table.database.name
else database_schema_table.get("database")
)
if isinstance(db_service_entity.connection.config, BigQueryConnection):
database_name = None
database_name = get_database_name_for_lineage(
db_service_entity, database_name
)

View File

@ -440,7 +440,7 @@ def is_safe_sql_query(sql_query: str) -> bool:
def get_database_name_for_lineage(
db_service_entity: DatabaseService, default_db_name: str
db_service_entity: DatabaseService, default_db_name: Optional[str]
) -> Optional[str]:
# If the database service supports multiple db or
# database service connection details are not available

View File

@ -27,6 +27,12 @@
"description": "Validate if the Owner information is retrieved for Workbooks",
"errorMessage": "Failed to fetch Workbook Owners, please validate if user has access to fetch Owners",
"mandatory": false
},
{
"name": "GetDataModels",
"description": "Validate if the Data Sources(Data Models) information is retrieved for Workbooks",
"errorMessage": "Failed to fetch Workbook Data Sources, please validate if user has access to fetch Data Sources and Metadata API is enabled for tableau server",
"mandatory": false
}
]
}

View File

@ -93,6 +93,10 @@
"title": "Supports Profiler",
"$ref": "../connectionBasicType.json#/definitions/supportsProfiler"
},
"supportsDatabase": {
"title": "Supports Database",
"$ref": "../connectionBasicType.json#/definitions/supportsDatabase"
},
"supportsQueryComment": {
"title": "Supports Query Comment",
"$ref": "../connectionBasicType.json#/definitions/supportsQueryComment"