ephraimbuddy commented on a change in pull request #21462:
URL: https://github.com/apache/airflow/pull/21462#discussion_r805854701
##########
File path: airflow/models/taskinstance.py
##########
@@ -2326,6 +2327,35 @@ def filter_for_tis(tis: Iterable[Union["TaskInstance",
TaskInstanceKey]]) -> Opt
).in_([ti.key.primary for ti in tis])
[email protected]_for(TaskInstance.__table__, "after_create")
+def add_index_taskinstance_mysql(*arg, **kw):
+ """Add an index for mysql"""
+ return CreateIndex(
+ Index(
+ 'ti_map_index',
+ TaskInstance.__table__.c.dag_id,
+ TaskInstance.__table__.c.task_id,
+ TaskInstance.__table__.c.run_id,
+ TaskInstance.__table__.c.map_index,
+ )
+ ).execute_if(dialect='mysql')(*arg, **kw)
+
+
[email protected]_for(TaskInstance.__table__, "after_create")
+def add_index_taskinstance_mssql(*arg, **kw):
+ """Add unique index for mssql"""
+ return CreateIndex(
+ Index(
+ 'ti_map_index',
+ TaskInstance.__table__.c.dag_id,
+ TaskInstance.__table__.c.task_id,
+ TaskInstance.__table__.c.run_id,
+ TaskInstance.__table__.c.map_index,
+ unique=True,
+ )
+ ).execute_if(dialect='mssql')(*arg, **kw)
Review comment:
I had to break it into two because `mysql` doesn't require the index to
be `unique`. Should I make it unique?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]