You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/05/04 18:49:31 UTC

[GitHub] [airflow] ashb commented on a diff in pull request #23491: Only count bad refs when `moved` table exists

ashb commented on code in PR #23491:
URL: https://github.com/apache/airflow/pull/23491#discussion_r865161337


##########
airflow/utils/db.py:
##########
@@ -1240,19 +1247,20 @@ class BadReferenceConfig:
         bad_rows_subquery = bad_ref_cfg.exists_func(session, source_table, **exists_func_kwargs)
         select_list = [x.label(x.name) for x in source_table.c]
         invalid_rows_query = session.query(*select_list).filter(~bad_rows_subquery.exists())
-        invalid_row_count = invalid_rows_query.count()
-        if invalid_row_count <= 0:
-            continue
 
         dangling_table_name = _format_airflow_moved_table_name(source_table.name, change_version, 'dangling')
         if dangling_table_name in existing_table_names:
-            yield _format_dangling_error(
-                source_table=source_table.name,
-                target_table=dangling_table_name,
-                invalid_count=invalid_row_count,
-                reason=f"without a corresponding {bad_ref_cfg.ref_table} row",
-            )
-            errored = True
+            invalid_row_count = invalid_rows_query.count()

Review Comment:
   The moved table can't be there already -- either the migration has already applied (and we created the moved table) or it's not yet applied and the table can't yet exist.
   
   But once the table exists we can't have anymore bad rows as there is a FK enforcing it.
   
   Am I missing something?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org