You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/12/13 16:10:39 UTC

[GitHub] [airflow] allebacco commented on a diff in pull request #28333: Allow a DAG to be scheduled when any related DataSet is updated

allebacco commented on code in PR #28333:
URL: https://github.com/apache/airflow/pull/28333#discussion_r1047373954


##########
airflow/migrations/versions/0123_2_6_0_add_dataset_schedule_mode_to_dag_model.py:
##########
@@ -0,0 +1,45 @@
+#
+# 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 dataset schedule mode to DAG model
+
+Revision ID: 7afd6d4021a9
+Revises: 290244fb8b83
+Create Date: 2022-12-13 11:34:26.648465
+
+"""
+
+from __future__ import annotations
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "7afd6d4021a9"
+down_revision = "290244fb8b83"
+branch_labels = None
+depends_on = None
+airflow_version = "2.6.0"
+
+
+def upgrade():
+    op.add_column("dag", sa.Column("run_on_any_dataset_changed", sa.Boolean(), nullable=False, default=False))

Review Comment:
   I like the any of condition for Datasets.
   
   I think that adding a column like `run_on_any_dataset_changed` is very coupled to the specific use case, while we should consider that the Dataset scheduling could be extended in the future with other scheduling rules.
   
   I am proposing to define a column named like `dataset_scheduling_[mode,rule,condition,...]` which may contains:
   * `ALL` string for scheduling after all datasets have been updated
   * `ANY` string for scheduling after any of the dataset has been updated
   
   In this way, it should be easy to extend the Dataset scheduling with more rules. E.g. we could also consider to use a JSON string for defining scheduling rules which trigger DAGs on the update of at least only a subset of the Datasets. I am not proposing to do it now, but having a string column like `dataset_scheduling_mode` could simplify the definition on new scheduling modes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org