Skip to content

Commit ffa2d47

Browse files
Update SQLAlchemy select() to new style (#30515)
SQLAlchemy has a new style for `select() that is standard for 2.0. This updates our uses of it to avoid `RemovedIn20Warning` warnings. https://docs.sqlalchemy.org/en/20/errors.html#select-construct-created-in-legacy-mode-keyword-arguments-etc
1 parent 73e0313 commit ffa2d47

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

airflow/migrations/versions/0093_2_2_0_taskinstance_keyed_to_dagrun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def _multi_table_update(dialect_name, target, column):
403403
if dialect_name == "sqlite":
404404
# Most SQLite versions don't support multi table update (and SQLA doesn't know about it anyway), so we
405405
# need to do a Correlated subquery update
406-
sub_q = select([dag_run.c[column.name]]).where(condition)
406+
sub_q = select(dag_run.c[column.name]).where(condition)
407407

408408
return target.update().values({column: sub_q})
409409
else:

airflow/migrations/versions/0104_2_3_0_migrate_rtif_to_use_run_id_and_map_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _multi_table_update(dialect_name, target, column):
9999
if dialect_name == "sqlite":
100100
# Most SQLite versions don't support multi table update (and SQLA doesn't know about it anyway), so we
101101
# need to do a Correlated subquery update
102-
sub_q = select([dag_run.c[column.name]]).where(condition)
102+
sub_q = select(dag_run.c[column.name]).where(condition)
103103

104104
return target.update().values({column: sub_q})
105105
else:

airflow/migrations/versions/0105_2_3_0_add_map_index_to_taskfail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _update_value_from_dag_run(
9595
if dialect_name == "sqlite":
9696
# Most SQLite versions don't support multi table update (and SQLA doesn't know about it anyway), so we
9797
# need to do a Correlated subquery update
98-
sub_q = select([dag_run.c[target_column.name]]).where(condition)
98+
sub_q = select(dag_run.c[target_column.name]).where(condition)
9999

100100
return target_table.update().values({target_column: sub_q})
101101
else:

airflow/models/dagrun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class DagRun(Base, LoggingMixin):
128128
log_template_id = Column(
129129
Integer,
130130
ForeignKey("log_template.id", name="task_instance_log_template_id_fkey", ondelete="NO ACTION"),
131-
default=select([func.max(LogTemplate.__table__.c.id)]),
131+
default=select(func.max(LogTemplate.__table__.c.id)),
132132
)
133133
updated_at = Column(UtcDateTime, default=timezone.utcnow, onupdate=timezone.utcnow)
134134

airflow/utils/db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ def _create_table_as(
11611161
if dialect_name == "mssql":
11621162
cte = source_query.cte("source")
11631163
moved_data_tbl = table(target_table_name, *(column(c.name) for c in cte.columns))
1164-
ins = moved_data_tbl.insert().from_select(list(cte.columns), select([cte]))
1164+
ins = moved_data_tbl.insert().from_select(list(cte.columns), select(cte))
11651165

11661166
stmt = ins.compile(bind=session.get_bind())
11671167
cte_sql = stmt.ctes[cte]
@@ -1200,7 +1200,7 @@ def _move_dangling_data_to_new_table(
12001200

12011201
target_table = source_table.to_metadata(source_table.metadata, name=target_table_name)
12021202
log.debug("checking whether rows were moved for table %s", target_table_name)
1203-
moved_rows_exist_query = select([1]).select_from(target_table).limit(1)
1203+
moved_rows_exist_query = select(1).select_from(target_table).limit(1)
12041204
first_moved_row = session.execute(moved_rows_exist_query).all()
12051205
session.commit()
12061206

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a6ec7b232fa919d38d4ef9f48a1db2968b68e878994554b15f311bd11ff1abb6
1+
b409a0826f10dc5ef934616fe2d5e72fff322bb1aebe321aad475e4d72c25a4f

0 commit comments

Comments
 (0)