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

Resolve warning in Dataset Alias migration #43421

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

kaxil
Copy link
Member

@kaxil kaxil commented Oct 27, 2024

This PR resolves an SQLAlchemy warning in the migration by correctly setting the alias_id column as part of the primary key in the dag_schedule_dataset_alias_reference table. Previously, only dag_id was marked as the primary key, causing a mismatch with the local definition, which triggered an SAWarning.

Example: https://github.com/apache/airflow/actions/runs/11526187767/job/32090094094?pr=43243#step:6:745

When running a migration you see this. It was missed in #41264:

/opt/airflow/airflow/migrations/versions/0026_2_10_0_dag_schedule_dataset_alias_reference.py:46 SAWarning: 
Table 'dag_schedule_dataset_alias_reference' specifies columns 'dag_id' as primary_key=True, not matching locally specified columns 'alias_id', 'dag_id'; setting the current primary key columns to 'alias_id', 'dag_id'. 
This warning may become an exception in a future release

It is already a primary key in models:

alias_id = Column(Integer, primary_key=True, nullable=False)
dag_id = Column(StringID(), primary_key=True, nullable=False)

I verified that both columns are marked as primary keys already in 2.10.

image

^ 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.

@kaxil kaxil requested a review from potiuk as a code owner October 27, 2024 21:24
@boring-cyborg boring-cyborg bot added the area:db-migrations PRs with DB migration label Oct 27, 2024
@kaxil kaxil removed the request for review from potiuk October 27, 2024 21:24
@kaxil kaxil requested review from Lee-W and uranusjr October 27, 2024 21:24
This PR resolves an SQLAlchemy warning in the migration by correctly setting the `alias_id` column as part of the primary key in the `dag_schedule_dataset_alias_reference` table. Previously, only dag_id was marked as the primary key, causing a mismatch with the local definition, which triggered an SAWarning.

Example: https://github.com/apache/airflow/actions/runs/11526187767/job/32090094094?pr=43243#step:6:745

```
/opt/airflow/airflow/migrations/versions/0026_2_10_0_dag_schedule_dataset_alias_reference.py:46 SAWarning: Table 'dag_schedule_dataset_alias_reference' specifies columns 'dag_id' as primary_key=True, not matching locally specified columns 'alias_id', 'dag_id'; setting the current primary key columns to 'alias_id', 'dag_id'. This warning may become an exception in a future release
```

I verified that both columns are marked as primary keys already in 2.10.
@Lee-W Lee-W merged commit f6ce1fd into apache:main Oct 28, 2024
52 checks passed
@Lee-W Lee-W deleted the resolve-warning-dsdar branch October 28, 2024 01:44
@utkarsharma2 utkarsharma2 added type:bug-fix Changelog: Bug Fixes type:misc/internal Changelog: Misc changes that should appear in change log and removed type:bug-fix Changelog: Bug Fixes labels Nov 1, 2024
ellisms pushed a commit to ellisms/airflow that referenced this pull request Nov 13, 2024
This PR resolves an SQLAlchemy warning in the migration by correctly setting the `alias_id` column as part of the primary key in the `dag_schedule_dataset_alias_reference` table. Previously, only dag_id was marked as the primary key, causing a mismatch with the local definition, which triggered an SAWarning.

Example: https://github.com/apache/airflow/actions/runs/11526187767/job/32090094094?pr=43243#step:6:745

```
/opt/airflow/airflow/migrations/versions/0026_2_10_0_dag_schedule_dataset_alias_reference.py:46 SAWarning: Table 'dag_schedule_dataset_alias_reference' specifies columns 'dag_id' as primary_key=True, not matching locally specified columns 'alias_id', 'dag_id'; setting the current primary key columns to 'alias_id', 'dag_id'. This warning may become an exception in a future release
```

I verified that both columns are marked as primary keys already in 2.10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:db-migrations PRs with DB migration kind:documentation type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants