This is an automated email from the ASF dual-hosted git repository.
taragolis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 5e58723fde Resolve SA warnings in migrations scripts (#39418)
5e58723fde is described below
commit 5e58723fde565e98d40d4744004dcab968898d2b
Author: Andrey Anshin <[email protected]>
AuthorDate: Tue May 7 02:02:02 2024 +0400
Resolve SA warnings in migrations scripts (#39418)
---
.../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 91bc59c164..85ad605e53 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
@@ -225,8 +225,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")
@@ -402,7 +401,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 5ff67b23a7..1194a20773 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
@@ -93,16 +93,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 f11f57c554..9d1b399983 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
@@ -100,7 +100,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 b6c41e83dc..06f6538dbe 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
@@ -96,7 +96,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 464463bb3f..5e0ad21ed6 100644
--- a/docs/apache-airflow/img/airflow_erd.sha256
+++ b/docs/apache-airflow/img/airflow_erd.sha256
@@ -1 +1 @@
-45e8aa557ff6c5c69995915206df2fef17495d5da04453e897cea73a8df0f492
\ No newline at end of file
+ec3c33d964d9afc51f0fbbee9bb2ef8c8dc496675a6ef96891a30d0403bb6823
\ 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 7225b0ce3e..019ff78714 100644
--- a/docs/apache-airflow/img/airflow_erd.svg
+++ b/docs/apache-airflow/img/airflow_erd.svg
@@ -1421,7 +1421,7 @@
<g id="edge45" class="edge">
<title>task_instance--xcom</title>
<path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2"
d="M1198.1,-703.32C1228.72,-680.46 1260.55,-657.41 1290.36,-636.54"/>
-<text text-anchor="start" x="1259.36" y="-625.34" font-family="Times,serif"
font-size="14.00">0..N</text>
+<text text-anchor="start" x="1280.36" y="-625.34" font-family="Times,serif"
font-size="14.00">1</text>
<text text-anchor="start" x="1198.1" y="-692.12" font-family="Times,serif"
font-size="14.00">1</text>
</g>
<!-- task_instance--xcom -->
@@ -1435,7 +1435,7 @@
<g id="edge47" class="edge">
<title>task_instance--xcom</title>
<path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2"
d="M1198.1,-729.94C1228.72,-707.76 1260.55,-684.48 1290.36,-662.44"/>
-<text text-anchor="start" x="1280.36" y="-666.24" font-family="Times,serif"
font-size="14.00">1</text>
+<text text-anchor="start" x="1259.36" y="-666.24" font-family="Times,serif"
font-size="14.00">0..N</text>
<text text-anchor="start" x="1198.1" y="-733.74" font-family="Times,serif"
font-size="14.00">1</text>
</g>
<!-- task_instance--xcom -->