MINOR: Fix column merge error lineage (#16670)

* MINOR: Fix Column merge error

* append only when col lineage available

* pyformat
This commit is contained in:
Mayur Singal 2024-06-17 09:02:21 +05:30 committed by GitHub
parent 60208a1990
commit 72ed09d6f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,11 +52,24 @@ class OMetaLineageMixin(Generic[T]):
self, original: List[Dict[str, Any]], updated: List[Dict[str, Any]]
):
temp_result = []
for column in original or []:
temp_result.append((*column.get("fromColumns", []), column.get("toColumn")))
for column in updated or []:
data = column.dict()
temp_result.append((*data.get("fromColumns", []), data.get("toColumn")))
try:
for column in original or []:
if column.get("toColumn") and column.get("fromColumns"):
temp_result.append(
(*column.get("fromColumns", []), column.get("toColumn"))
)
for column in updated or []:
if not isinstance(column, dict):
data = column.dict()
else:
data = column
if data.get("toColumn") and data.get("fromColumns"):
temp_result.append(
(*data.get("fromColumns", []), data.get("toColumn"))
)
except Exception as exc:
logger.debug(f"Error while merging column lineage: {exc}")
logger.debug(traceback.format_exc())
return [
{"fromColumns": list(col_data[:-1]), "toColumn": col_data[-1]}
for col_data in set(temp_result)