You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ur...@apache.org on 2022/01/26 09:41:52 UTC
[airflow] branch main updated: Add constraint to ensure task map length >= 0 (#21115)
This is an automated email from the ASF dual-hosted git repository.
uranusjr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 80f30ee Add constraint to ensure task map length >= 0 (#21115)
80f30ee is described below
commit 80f30ee589f0ccbeaae5568976b40917ffd66d7f
Author: Tzu-ping Chung <tp...@astronomer.io>
AuthorDate: Wed Jan 26 17:40:54 2022 +0800
Add constraint to ensure task map length >= 0 (#21115)
---
.../versions/e655c0453f75_add_taskmap_and_map_id_on_taskinstance.py | 3 ++-
airflow/models/taskmap.py | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/airflow/migrations/versions/e655c0453f75_add_taskmap_and_map_id_on_taskinstance.py b/airflow/migrations/versions/e655c0453f75_add_taskmap_and_map_id_on_taskinstance.py
index 106dffc..1b7b926 100644
--- a/airflow/migrations/versions/e655c0453f75_add_taskmap_and_map_id_on_taskinstance.py
+++ b/airflow/migrations/versions/e655c0453f75_add_taskmap_and_map_id_on_taskinstance.py
@@ -24,7 +24,7 @@ Create Date: 2021-12-13 22:59:41.052584
"""
from alembic import op
-from sqlalchemy import Column, ForeignKeyConstraint, Integer, text
+from sqlalchemy import CheckConstraint, Column, ForeignKeyConstraint, Integer, text
from airflow.models.base import StringID
from airflow.utils.sqlalchemy import ExtendedJSON
@@ -75,6 +75,7 @@ def upgrade():
Column("map_index", Integer, primary_key=True),
Column("length", Integer, nullable=False),
Column("keys", ExtendedJSON, nullable=True),
+ CheckConstraint("length >= 0", name="task_map_length_not_negative"),
ForeignKeyConstraint(
["dag_id", "task_id", "run_id", "map_index"],
[
diff --git a/airflow/models/taskmap.py b/airflow/models/taskmap.py
index e91fbd6..3945e2d 100644
--- a/airflow/models/taskmap.py
+++ b/airflow/models/taskmap.py
@@ -22,7 +22,7 @@ import collections.abc
import enum
from typing import TYPE_CHECKING, Any, Collection, List, Optional
-from sqlalchemy import Column, ForeignKeyConstraint, Integer, String
+from sqlalchemy import CheckConstraint, Column, ForeignKeyConstraint, Integer, String
from airflow.models.base import COLLATION_ARGS, ID_LEN, Base
from airflow.utils.sqlalchemy import ExtendedJSON
@@ -61,6 +61,7 @@ class TaskMap(Base):
keys = Column(ExtendedJSON, nullable=True)
__table_args__ = (
+ CheckConstraint(length >= 0, name="task_map_length_not_negative"),
ForeignKeyConstraint(
[dag_id, task_id, run_id, map_index],
[