uranusjr commented on code in PR #26761:
URL: https://github.com/apache/airflow/pull/26761#discussion_r994147098
##########
airflow/providers/common/sql/operators/sql.py:
##########
@@ -229,49 +236,75 @@ def __init__(
**kwargs,
):
super().__init__(conn_id=conn_id, database=database, **kwargs)
- for checks in column_mapping.values():
- for check, check_values in checks.items():
- self._column_mapping_validation(check, check_values)
self.table = table
self.column_mapping = column_mapping
self.partition_clause = partition_clause
- # OpenLineage needs a valid SQL query with the input/output table(s)
to parse
- self.sql = f"SELECT * FROM {self.table};"
+
+ checks_sql_list = []
+ for column, checks in self.column_mapping.items():
+ for check, check_values in checks.items():
+ self._column_mapping_validation(check, check_values)
+ checks_sql_list.append(self._generate_sql_query(column, checks))
+ checks_sql = "UNION ALL".join(checks_sql_list)
Review Comment:
```suggestion
def _build_checks_sql():
for column, checks in self.column_mapping.items():
for check, check_values in checks.items():
self._column_mapping_validation(check, check_values)
yield self._generate_sql_query(column, checks)
checks_sql = "UNION ALL".join(_build_checks_sql())
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]