uranusjr commented on code in PR #29999:
URL: https://github.com/apache/airflow/pull/29999#discussion_r1133477557
##########
airflow/utils/db_cleanup.py:
##########
@@ -150,18 +150,28 @@ def _do_delete(*, query, orm_model, skip_archive,
session):
timestamp_str = re.sub(r"[^\d]", "", datetime.utcnow().isoformat())[:14]
target_table_name =
f"{ARCHIVE_TABLE_PREFIX}{orm_model.name}__{timestamp_str}"
print(f"Moving data to table {target_table_name}")
- stmt = CreateTableAs(target_table_name, query.selectable)
- logger.debug("ctas query:\n%s", stmt.compile())
- session.execute(stmt)
+ bind = session.get_bind()
+ dialect_name = bind.dialect.name
+ if dialect_name == "mysql":
+ # MySQL with replication needs this split into two queries, so just do
it for all MySQL
+ # ERROR 1786 (HY000): Statement violates GTID consistency: CREATE
TABLE ... SELECT.
+ session.execute(f"CREATE TABLE {target_table_name} LIKE
{orm_model.name}")
Review Comment:
Instead of writing custom SQL here, would it be better to enhance
`CreateTableAs` compilation to support the MySQL syntax instead?
--
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]