in src/package/dataplexutils/metadata/wizard.py [0:0]
def _get_table_sources(self, table_fqn):
"""Add stringdocs
Args:
Add stringdocs
Raises:
Add stringdocs
"""
try:
lineage_client = self._cloud_clients[
constants["CLIENTS"]["DATA_CATALOG_LINEAGE"]
]
target = datacatalog_lineage_v1.EntityReference()
target.fully_qualified_name = f"bigquery:{table_fqn}"
target_dataset=str(self._get_dataset_location(table_fqn)).lower()
logger.info(f"_get_table_sources:Searching for lineage links for table {table_fqn}. in dataset {target_dataset}")
request = datacatalog_lineage_v1.SearchLinksRequest(
parent=f"projects/{self._project_id}/locations/{target_dataset}",
target=target,
)
link_results = lineage_client.search_links(request=request)
table_sources = []
for link in link_results:
if link.target == target:
table_sources.append(
link.source.fully_qualified_name.replace("bigquery:", "")
)
return table_sources
except Exception as e:
logger.error(f"Exception: {e}.")
raise e