-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
Fixed rows count in the migration script #34348
Conversation
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
|
@@ -1446,7 +1446,7 @@ class BadReferenceConfig: | |||
|
|||
dangling_table_name = _format_airflow_moved_table_name(source_table.name, change_version, "dangling") | |||
if dangling_table_name in existing_table_names: | |||
invalid_row_count = bad_rows_query.count() | |||
invalid_row_count = get_query_count(bad_rows_query, session=session) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test to protect future changes here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will add it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ephraimbuddy I've finally found the time to add the test, although it required more work than expected :)
@@ -0,0 +1 @@ | |||
Fixed ``AttributeError: 'Select' object has no attribute 'count'`` during the ``airflow db migrate`` command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have but not required
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
* Fixed row count for SQLAlchemy 1.4+ * Updated newsfragments * Fixed typo * Added newline * Added test for `check_bad_references` (cherry picked from commit f349fda)
Changes:
.count()
method with an already existingget_query_count
method;Motivation:
While performing the Apache Airflow update from 2.2.3 to 2.7.1 I faced an issue with the migration:
The cause of the error is that SQLAlchemy changed the behavior of the
select
statement. It has already been addressed in other places usingfunc.count()
, so the problematic line looks more like a typo/oversight.^ 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 newsfragments.