This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-9-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit a76bb7bd57ae8036638770289ad3e2c66a8fabcc Author: Andrey Anshin <[email protected]> AuthorDate: Tue May 7 02:02:02 2024 +0400 Resolve SA warnings in migrations scripts (#39418) (cherry picked from commit 5e58723fde565e98d40d4744004dcab968898d2b) --- .../0093_2_2_0_taskinstance_keyed_to_dagrun.py | 5 ++--- .../0102_2_3_0_switch_xcom_table_to_use_run_id.py | 18 ++++++++---------- ...4_2_3_0_migrate_rtif_to_use_run_id_and_map_index.py | 2 +- .../versions/0105_2_3_0_add_map_index_to_taskfail.py | 2 +- docs/apache-airflow/img/airflow_erd.sha256 | 2 +- docs/apache-airflow/img/airflow_erd.svg | 4 ++-- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/airflow/migrations/versions/0093_2_2_0_taskinstance_keyed_to_dagrun.py b/airflow/migrations/versions/0093_2_2_0_taskinstance_keyed_to_dagrun.py index 42e4aaa0ae..1863358db9 100644 --- a/airflow/migrations/versions/0093_2_2_0_taskinstance_keyed_to_dagrun.py +++ b/airflow/migrations/versions/0093_2_2_0_taskinstance_keyed_to_dagrun.py @@ -224,8 +224,7 @@ def upgrade(): constraints = get_mssql_table_constraints(conn, "task_instance") pk, _ = constraints["PRIMARY KEY"].popitem() batch_op.drop_constraint(pk, type_="primary") - elif dialect_name not in ("sqlite"): - batch_op.drop_constraint("task_instance_pkey", type_="primary") + batch_op.drop_constraint("task_instance_pkey", type_="primary") batch_op.drop_index("ti_dag_date") batch_op.drop_index("ti_state_lkp") batch_op.drop_column("execution_date") @@ -401,7 +400,7 @@ def _multi_table_update(dialect_name, target, column): if dialect_name == "sqlite": # Most SQLite versions don't support multi table update (and SQLA doesn't know about it anyway), so we # need to do a Correlated subquery update - sub_q = select(dag_run.c[column.name]).where(condition) + sub_q = select(dag_run.c[column.name]).where(condition).scalar_subquery() return target.update().values({column: sub_q}) else: diff --git a/airflow/migrations/versions/0102_2_3_0_switch_xcom_table_to_use_run_id.py b/airflow/migrations/versions/0102_2_3_0_switch_xcom_table_to_use_run_id.py index 5a0702a682..3584c1a4bc 100644 --- a/airflow/migrations/versions/0102_2_3_0_switch_xcom_table_to_use_run_id.py +++ b/airflow/migrations/versions/0102_2_3_0_switch_xcom_table_to_use_run_id.py @@ -92,16 +92,14 @@ def upgrade(): xcom = Table("xcom", metadata, *_get_old_xcom_columns()) dagrun = _get_dagrun_table() query = select( - [ - dagrun.c.id, - xcom.c.task_id, - xcom.c.key, - xcom.c.value, - xcom.c.timestamp, - xcom.c.dag_id, - dagrun.c.run_id, - literal_column("-1"), - ], + dagrun.c.id, + xcom.c.task_id, + xcom.c.key, + xcom.c.value, + xcom.c.timestamp, + xcom.c.dag_id, + dagrun.c.run_id, + literal_column("-1"), ).select_from( xcom.join( right=dagrun, diff --git a/airflow/migrations/versions/0104_2_3_0_migrate_rtif_to_use_run_id_and_map_index.py b/airflow/migrations/versions/0104_2_3_0_migrate_rtif_to_use_run_id_and_map_index.py index ea03bceb69..7c11ec3913 100644 --- a/airflow/migrations/versions/0104_2_3_0_migrate_rtif_to_use_run_id_and_map_index.py +++ b/airflow/migrations/versions/0104_2_3_0_migrate_rtif_to_use_run_id_and_map_index.py @@ -99,7 +99,7 @@ def _multi_table_update(dialect_name, target, column): if dialect_name == "sqlite": # Most SQLite versions don't support multi table update (and SQLA doesn't know about it anyway), so we # need to do a Correlated subquery update - sub_q = select(dag_run.c[column.name]).where(condition) + sub_q = select(dag_run.c[column.name]).where(condition).scalar_subquery() return target.update().values({column: sub_q}) else: diff --git a/airflow/migrations/versions/0105_2_3_0_add_map_index_to_taskfail.py b/airflow/migrations/versions/0105_2_3_0_add_map_index_to_taskfail.py index 92abdafeb3..649c502135 100644 --- a/airflow/migrations/versions/0105_2_3_0_add_map_index_to_taskfail.py +++ b/airflow/migrations/versions/0105_2_3_0_add_map_index_to_taskfail.py @@ -95,7 +95,7 @@ def _update_value_from_dag_run( if dialect_name == "sqlite": # Most SQLite versions don't support multi table update (and SQLA doesn't know about it anyway), so we # need to do a Correlated subquery update - sub_q = select(dag_run.c[target_column.name]).where(condition) + sub_q = select(dag_run.c[target_column.name]).where(condition).scalar_subquery() return target_table.update().values({target_column: sub_q}) else: diff --git a/docs/apache-airflow/img/airflow_erd.sha256 b/docs/apache-airflow/img/airflow_erd.sha256 index 69c772e5b1..84f3b91bf9 100644 --- a/docs/apache-airflow/img/airflow_erd.sha256 +++ b/docs/apache-airflow/img/airflow_erd.sha256 @@ -1 +1 @@ -00b4a76587ea1f5f2f317a555a083a0b4964c727d0a3c8c2044ac4f19c58abd4 \ No newline at end of file +a82d08fd5d725c40dab022228ac57a514851c1718c21fe8712ff5f12698b5d1f \ No newline at end of file diff --git a/docs/apache-airflow/img/airflow_erd.svg b/docs/apache-airflow/img/airflow_erd.svg index 2b338b6d51..3dbb55dd4b 100644 --- a/docs/apache-airflow/img/airflow_erd.svg +++ b/docs/apache-airflow/img/airflow_erd.svg @@ -1368,7 +1368,7 @@ <g id="edge42" class="edge"> <title>task_instance--xcom</title> <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" d="M1198.1,-818.52C1228.72,-815.1 1260.55,-811.78 1290.36,-808.91"/> -<text text-anchor="start" x="1280.36" y="-812.71" font-family="Times,serif" font-size="14.00">1</text> +<text text-anchor="start" x="1259.36" y="-812.71" font-family="Times,serif" font-size="14.00">0..N</text> <text text-anchor="start" x="1198.1" y="-822.32" font-family="Times,serif" font-size="14.00">1</text> </g> <!-- task_instance--xcom --> @@ -1382,7 +1382,7 @@ <g id="edge44" class="edge"> <title>task_instance--xcom</title> <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" d="M1198.1,-845.13C1228.72,-842.41 1260.55,-838.85 1290.36,-834.82"/> -<text text-anchor="start" x="1259.36" y="-838.62" font-family="Times,serif" font-size="14.00">0..N</text> +<text text-anchor="start" x="1280.36" y="-838.62" font-family="Times,serif" font-size="14.00">1</text> <text text-anchor="start" x="1198.1" y="-848.93" font-family="Times,serif" font-size="14.00">1</text> </g> <!-- rendered_task_instance_fields -->
