tanvn commented on code in PR #29999:
URL: https://github.com/apache/airflow/pull/29999#discussion_r1133487924
##########
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:
@uranusjr I would love to do so but I am new to sqlalchemy and at first I do
not know how to let the compiler to execute 2 queries instead of one?
(I just took a quick look at
https://docs.sqlalchemy.org/en/20/core/compiler.html#dialect-specific-compilation-rules)
--
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]