You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/12/03 12:33:51 UTC

[GitHub] [airflow] ashb commented on a change in pull request #19999: Don't use CREATE TABLE AS SELECT ... with mySQL

ashb commented on a change in pull request #19999:
URL: https://github.com/apache/airflow/pull/19999#discussion_r761896632



##########
File path: airflow/utils/db.py
##########
@@ -737,13 +737,24 @@ def _move_dangling_table(session, source_table: "Table", target_table_name: str,
             )
         )
     else:
-        # Postgres, MySQL and SQLite all have the same CREATE TABLE a AS SELECT ... syntax
-        session.execute(
-            text(
-                f"create table {target_table_name} as select source.* from {source_table} as source "
-                + where_clause
+        if dialect_name == "mysql":
+            # CREATE TABLE AS SELECT must be broken into two queries in mySQL for GTID consistency.
+            # More info: https://github.com/apache/airflow/issues/19988

Review comment:
       ```suggestion
               # CREATE TABLE AS SELECT must be broken into two queries for  MySQL as the single query
               # approach fails when replication is enabled ("Statement violates GTID consistency")```




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org