-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Soft delete datasets that are no longer referenced in DAG schedules o…
…r task outlets (#27828) * Soft delete datasets that are no longer referenced anywhere * Move the orphaning logic into the scheduler and adjust config option name accordingly * Rename config option scheduler.cleanup_interval -> scheduler.parsing_cleanup_interval * Include default column value in migration * deprecate old interval config; move code to scheduler_job * First pass at a test * Fix migration * Apply suggestions from code review Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com> * Don't batch migrations if we don't need to * Revert "Don't batch migrations if we don't need to" - gotta batch migrations for SQLite This reverts commit 652f745. * Tweak migrations * Use sqlalchemy.sql.True_() to support all DB backends * Various cleanups * Add test for un-orphaning datasets once they are referenced again * Use sqlalchemy.sql.expression.true() Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com> * Fix orphaning datasets on MSSQL * Comment the un-orphan process and use sqla.sql.expression.false() * Add newsfragment about renamed config option * add mssql_drop_default flag * Use server_default in the ORM as well * Defensively clear datasets before and after DAG tests * Reconcile migration with ORM model * Remove now erroneous comment * Change to use server_default='0' * Update airflow/configuration.py Co-authored-by: Jed Cunningham <jedcunningham@apache.org> Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com> Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com>
- Loading branch information
1 parent
3e288ab
commit 3fef6a4
Showing
15 changed files
with
422 additions
and
215 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
57 changes: 57 additions & 0 deletions
57
airflow/migrations/versions/0122_2_5_0_add_is_orphaned_to_datasetmodel.py
This file contains 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,57 @@ | ||
# | ||
# 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. | ||
|
||
"""Add is_orphaned to DatasetModel | ||
Revision ID: 290244fb8b83 | ||
Revises: 1986afd32c1b | ||
Create Date: 2022-11-22 00:12:53.432961 | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "290244fb8b83" | ||
down_revision = "1986afd32c1b" | ||
branch_labels = None | ||
depends_on = None | ||
airflow_version = "2.5.0" | ||
|
||
|
||
def upgrade(): | ||
"""Add is_orphaned to DatasetModel""" | ||
with op.batch_alter_table("dataset") as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"is_orphaned", | ||
sa.Boolean, | ||
default=False, | ||
nullable=False, | ||
server_default="0", | ||
) | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Remove is_orphaned from DatasetModel""" | ||
with op.batch_alter_table("dataset") as batch_op: | ||
batch_op.drop_column("is_orphaned", mssql_drop_default=True) |
This file contains 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 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 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 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 @@ | ||
f529521071a6c9ae8bbd58d63cf1195fc1ec964308e7684569d0a36d26534def | ||
5bee32cf7239656360cfe7978e7f01d6ee3b9914d3f3fd89ed4ff747254dddf8 |
Oops, something went wrong.