Skip to content

Commit

Permalink
Apply specific ID collation to root_dag_id too (#23536)
Browse files Browse the repository at this point in the history
In certain databases there is a need to set the collation for ID fields
like dag_id or task_id to something different than the database default.
This is because in MySQL with utf8mb4 the index size becomes too big for
the MySQL limits. In past pull requests this was handled
[#7570](apache/airflow#7570),
[#17729](apache/airflow#17729), but the
root_dag_id field on the dag model was missed. Since this field is used
to join with the dag_id in various other models ([and
self-referentially](https://github.com/apache/airflow/blob/451c7cbc42a83a180c4362693508ed33dd1d1dab/airflow/models/dag.py#L2766)),
it also needs to have the same collation as other ID fields.

This can be seen by running `airflow db reset` before and after applying
this change while also specifying `sql_engine_collation_for_ids` in the
configuration.

Other related PRs
[#19408](apache/airflow#19408)

GitOrigin-RevId: b7f862760ce4e20a284bb1933c9078e54851c518
  • Loading branch information
mpeteuil authored and Cloud Composer Team committed Jan 27, 2023
1 parent 3dccc9d commit 061701b
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import sqlalchemy as sa
from alembic import op

from airflow.migrations.db_types import StringID

# revision identifiers, used by Alembic.
revision = 'b3b105409875'
down_revision = 'd38e04c12aa2'
Expand All @@ -37,7 +39,7 @@

def upgrade():
"""Apply Add ``root_dag_id`` to ``DAG``"""
op.add_column('dag', sa.Column('root_dag_id', sa.String(length=250), nullable=True))
op.add_column('dag', sa.Column('root_dag_id', StringID(), nullable=True))
op.create_index('idx_root_dag_id', 'dag', ['root_dag_id'], unique=False)


Expand Down

0 comments on commit 061701b

Please sign in to comment.