-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Make dag_version_id in TI non-nullable #50825
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
Merged
ephraimbuddy
merged 39 commits into
apache:main
from
astronomer:make-ti-dag-version-id-non-nullable2
Jul 8, 2025
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
5c794b8
Make dag_version_id in TI non-nullable
ephraimbuddy 203536d
fixup! Make dag_version_id in TI non-nullable
ephraimbuddy 21918b0
Fix tests for some providers
ephraimbuddy 83681f6
fixup! Fix tests for some providers
ephraimbuddy 4675b20
fixup! fixup! Fix tests for some providers
ephraimbuddy 9be5b3b
more test fixes
ephraimbuddy fb18650
fixup! more test fixes
ephraimbuddy ff25459
fixup! fixup! more test fixes
ephraimbuddy 4e3a9c6
Update more tests
ephraimbuddy 050cb50
fixup! Update more tests
ephraimbuddy b721be8
fixup! fixup! Update more tests
ephraimbuddy b5bd21e
fixup! fixup! fixup! Update more tests
ephraimbuddy bde9818
fixup! fixup! fixup! fixup! Update more tests
ephraimbuddy ccd5257
fixup! fixup! fixup! fixup! fixup! Update more tests
ephraimbuddy 5f3f29a
Add compat for MockedTaskInstance
ephraimbuddy 8357ecf
fixup! Add compat for MockedTaskInstance
ephraimbuddy 08336cd
fixup! fixup! Add compat for MockedTaskInstance
ephraimbuddy b208906
fix system test
ephraimbuddy 6e5497d
fixup! fix system test
ephraimbuddy 538c6ce
A fix for kube integration tests
ephraimbuddy 448d58c
Update the expected TIs from test multiple versions number file
ephraimbuddy ec42bf9
fix incorrect imports
ephraimbuddy 7c7c03d
fix time delta async test
ephraimbuddy 86aa622
Remove non working kube test fix
ephraimbuddy b78cc59
Fix task sdk test
ephraimbuddy d5fcb1d
Add cadwyn migration and fix some tests
ephraimbuddy 192c69e
fix some provider tests
ephraimbuddy b24ef32
Add data migration before migrating dag_version_id
ephraimbuddy 9ccfd0b
Update test, TaskInstanceResponse and fix assert dag_version in task_…
ephraimbuddy 7e58b23
Resolve conflicts
ephraimbuddy 27e07ae
Fix test
ephraimbuddy b461d67
Fix more tests
ephraimbuddy 15bda9d
fixup! fixup! Fix more tests
ephraimbuddy 4bc2e2c
Fix bad rebase
ephraimbuddy 2890710
update fab www-hash
ephraimbuddy c6afa74
Fix conflicts
ephraimbuddy f3c6444
Fix MappedTaskInstancedata
ephraimbuddy 743e188
add dag_version_id to a new test
ephraimbuddy 43428f4
Fix fab www hash
ephraimbuddy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 72b7bb2d4e109d8f786d229e68c83d2b6f7442e48a6617ea3d47842f1bfa33eb | ||
| e0de73aab81a28995b99be21dd25c8ca31c4e0f4a5a0a26df8aff412e5067fd5 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_08_10.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from cadwyn import VersionChange, schema | ||
|
|
||
| from airflow.api_fastapi.execution_api.datamodels.taskinstance import TaskInstance | ||
|
|
||
|
|
||
| class AddDagVersionIdField(VersionChange): | ||
| """Add the `dag_version_id` field to the TaskInstance model.""" | ||
|
|
||
| description = __doc__ | ||
|
|
||
| instructions_to_migrate_to_previous_version = (schema(TaskInstance).field("dag_version_id").didnt_exist,) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...w-core/src/airflow/migrations/versions/0076_3_1_0_make_dag_version_id_non_nullable_in_.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| """ | ||
| Make dag_version_id non-nullable in TaskInstance. | ||
|
|
||
| Revision ID: 5d3072c51bac | ||
| Revises: ffdb0566c7c0 | ||
| Create Date: 2025-05-20 10:38:25.635779 | ||
|
|
||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
| from sqlalchemy_utils import UUIDType | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "5d3072c51bac" | ||
| down_revision = "ffdb0566c7c0" | ||
| branch_labels = None | ||
| depends_on = None | ||
| airflow_version = "3.1.0" | ||
|
|
||
|
|
||
| def upgrade(): | ||
| """Apply make dag_version_id non-nullable in TaskInstance.""" | ||
| conn = op.get_bind() | ||
| if conn.dialect.name == "postgresql": | ||
| update_query = sa.text(""" | ||
| UPDATE task_instance | ||
| SET dag_version_id = latest_versions.id | ||
| FROM ( | ||
| SELECT DISTINCT ON (dag_id) dag_id, id | ||
| FROM dag_version | ||
| ORDER BY dag_id, created_at DESC | ||
| ) latest_versions | ||
| WHERE task_instance.dag_id = latest_versions.dag_id | ||
| AND task_instance.dag_version_id IS NULL | ||
| """) | ||
| else: | ||
| update_query = sa.text(""" | ||
| UPDATE task_instance | ||
| SET dag_version_id = ( | ||
| SELECT id FROM ( | ||
| SELECT id, dag_id, | ||
| ROW_NUMBER() OVER (PARTITION BY dag_id ORDER BY created_at DESC) as rn | ||
| FROM dag_version | ||
| ) ranked_versions | ||
| WHERE ranked_versions.dag_id = task_instance.dag_id | ||
| AND ranked_versions.rn = 1 | ||
| ) | ||
| WHERE task_instance.dag_version_id IS NULL | ||
| """) | ||
|
|
||
| op.execute(update_query) | ||
|
|
||
| with op.batch_alter_table("task_instance", schema=None) as batch_op: | ||
| batch_op.alter_column("dag_version_id", existing_type=UUIDType(binary=False), nullable=False) | ||
|
|
||
|
|
||
| def downgrade(): | ||
| """Unapply make dag_version_id non-nullable in TaskInstance.""" | ||
| with op.batch_alter_table("task_instance", schema=None) as batch_op: | ||
| batch_op.alter_column("dag_version_id", existing_type=UUIDType(binary=False), nullable=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.