Skip to content

Conversation

@kunaljubce
Copy link
Contributor

@kunaljubce kunaljubce commented Dec 26, 2025

Issue description: #59402


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg bot added area:dev-tools area:Scheduler including HA (high availability) scheduler backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch labels Dec 26, 2025
@kunaljubce kunaljubce changed the title Compatibility updates for sqlalchemy 2.0 Sqlalchemy 2.0 changes for Dec 26, 2025
@kunaljubce kunaljubce changed the title Sqlalchemy 2.0 changes for Sqlalchemy 2.0 changes for test_scheduler_job.py Dec 26, 2025
@shahar1 shahar1 requested a review from Copilot December 26, 2025 15:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates test_scheduler_job.py to SQLAlchemy 2.0 syntax by replacing legacy .query() API calls with the modern select() construct. The changes remove deprecated SQLAlchemy 1.4 compatibility code and align with SQLAlchemy 2.0 best practices.

Key changes:

  • Replaced .query().filter() patterns with session.scalars(select().where()) for retrieving objects
  • Replaced .query().filter().scalar() with session.scalar(select().where()) for scalar values
  • Updated count operations from .query().count() to len(session.scalars(select()).all()) or session.scalar(select(func.count()))
  • Removed imports and conditional logic for SQLALCHEMY_V_1_4 and SQLALCHEMY_V_2_0 version checks

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
airflow-core/tests/unit/jobs/test_scheduler_job.py Migrated all SQLAlchemy query operations from legacy .query() API to 2.0-style select() constructs, removed version compatibility code, and added proper .unique() calls for joinedload queries
.pre-commit-config.yaml Added test_scheduler_job.py to the list of files checked by pre-commit hooks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@shahar1 shahar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please address issues raised by Copilot?

@kunaljubce
Copy link
Contributor Author

Could you please address issues raised by Copilot?

yeah I will get to these over the weekend

Copy link
Contributor

@Prab-27 Prab-27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, great work!

@potiuk potiuk merged commit bd8e0d3 into apache:main Dec 28, 2025
68 checks passed
@potiuk
Copy link
Member

potiuk commented Dec 28, 2025

Nice :) Thanks!

@github-actions
Copy link

Backport failed to create: v3-1-test. View the failure log Run details

Status Branch Result
v3-1-test Commit Link

You can attempt to backport this manually by running:

cherry_picker bd8e0d3 v3-1-test

This should apply the commit to the v3-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

chirodip98 pushed a commit to chirodip98/airflow-contrib that referenced this pull request Dec 28, 2025
* Compatibility updates for sqlalchemy 2.0

* Fixes for review comments

* Fixes for review comments

* More fixes for review comments
amoghrajesh pushed a commit to astronomer/airflow that referenced this pull request Dec 29, 2025
* Compatibility updates for sqlalchemy 2.0

* Fixes for review comments

* Fixes for review comments

* More fixes for review comments
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Jan 2, 2026
* Compatibility updates for sqlalchemy 2.0

* Fixes for review comments

* Fixes for review comments

* More fixes for review comments
stegololz pushed a commit to stegololz/airflow that referenced this pull request Jan 9, 2026
* Compatibility updates for sqlalchemy 2.0

* Fixes for review comments

* Fixes for review comments

* More fixes for review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:Scheduler including HA (high availability) scheduler backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants