Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SQLAlchemy select() to new style #30515

Merged
merged 2 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,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)

return target.update().values({column: sub_q})
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

return target.update().values({column: sub_q})
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

return target_table.update().values({target_column: sub_q})
else:
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/dagrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class DagRun(Base, LoggingMixin):
log_template_id = Column(
Integer,
ForeignKey("log_template.id", name="task_instance_log_template_id_fkey", ondelete="NO ACTION"),
default=select([func.max(LogTemplate.__table__.c.id)]),
default=select(func.max(LogTemplate.__table__.c.id)),
)
updated_at = Column(UtcDateTime, default=timezone.utcnow, onupdate=timezone.utcnow)

Expand Down
4 changes: 2 additions & 2 deletions airflow/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ def _create_table_as(
if dialect_name == "mssql":
cte = source_query.cte("source")
moved_data_tbl = table(target_table_name, *(column(c.name) for c in cte.columns))
ins = moved_data_tbl.insert().from_select(list(cte.columns), select([cte]))
ins = moved_data_tbl.insert().from_select(list(cte.columns), select(cte))

stmt = ins.compile(bind=session.get_bind())
cte_sql = stmt.ctes[cte]
Expand Down Expand Up @@ -1200,7 +1200,7 @@ def _move_dangling_data_to_new_table(

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

Expand Down
2 changes: 1 addition & 1 deletion docs/apache-airflow/img/airflow_erd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a6ec7b232fa919d38d4ef9f48a1db2968b68e878994554b15f311bd11ff1abb6
b409a0826f10dc5ef934616fe2d5e72fff322bb1aebe321aad475e4d72c25a4f