Skip to content

Commit

Permalink
ISSUE-17045: Modified to create column linage even when upstream colu…
Browse files Browse the repository at this point in the history
…mns and data source columns are one-to-many (#17112)

Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com>
  • Loading branch information
kwgdaig and pmbrull authored Aug 22, 2024
1 parent 3d8d856 commit 43a244f
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,18 @@ def yield_dashboard(
@staticmethod
def _get_data_model_column_fqn(
data_model_entity: DashboardDataModel, column: str
) -> Optional[str]:
) -> Optional[List[str]]:
"""
Get fqn of column if exist in table entity
"""
if not data_model_entity:
return None
columns = []
for tbl_column in data_model_entity.columns:
for child_column in tbl_column.children or []:
if column.lower() == child_column.name.root.lower():
return child_column.fullyQualifiedName.root
return None
columns.append(child_column.fullyQualifiedName.root)
return columns

def _get_column_lineage( # pylint: disable=arguments-differ
self,
Expand All @@ -342,13 +343,15 @@ def _get_column_lineage( # pylint: disable=arguments-differ
from_column = get_column_fqn(
table_entity=table_entity, column=column.name
)
to_column = self._get_data_model_column_fqn(
to_columns = self._get_data_model_column_fqn(
data_model_entity=data_model_entity,
column=column.id,
)
column_lineage.append(
ColumnLineage(fromColumns=[from_column], toColumn=to_column)
)
for to_column in to_columns:
column_lineage.append(
ColumnLineage(fromColumns=[from_column], toColumn=to_column)
)
return column_lineage
except Exception as exc:
logger.debug(f"Error to get column lineage: {exc}")
logger.debug(traceback.format_exc())
Expand Down

0 comments on commit 43a244f

Please sign in to comment.