potiuk commented on code in PR #37246:
URL: https://github.com/apache/airflow/pull/37246#discussion_r1482983258


##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -486,32 +486,36 @@ def _generate_insert_sql(self, table, values, 
target_fields, replace, **kwargs)
         """
         Generate the INSERT SQL statement.
 
-        The REPLACE variant is specific to MySQL syntax.
+        The REPLACE variant is specific to MySQL syntax, the UPSERT variant is 
specific to SAP Hana syntax
 
         :param table: Name of the target table
         :param values: The row to insert into the table
         :param target_fields: The names of the columns to fill in the table
-        :param replace: Whether to replace instead of insert
-        :return: The generated INSERT or REPLACE SQL statement
+        :param replace: Whether to replace/upsert instead of insert
+        :return: The generated INSERT or REPLACE/UPSERT SQL statement
         """
         placeholders = [
-            self.placeholder,
-        ] * len(values)
+                           self.placeholder,
+                       ] * len(values)
 
         if target_fields:
             target_fields = ", ".join(target_fields)
             target_fields = f"({target_fields})"
         else:
             target_fields = ""
 
+        sql = f"{table} {target_fields} VALUES ({','.join(placeholders)})"
+
         if not replace:
-            sql = "INSERT INTO "
-        else:
-            sql = "REPLACE INTO "
-        sql += f"{table} {target_fields} VALUES ({','.join(placeholders)})"
-        return sql
+            return f"INSERT INTO {sql}"
+
+        if self.get_sqlalchemy_engine().dialect.name == "hana":

Review Comment:
   This should not be here. You should make this extensible (so that Hooks 
deriving from DBApi might overwrite returned query). The "common" hook should 
not be aware of any particular implementation or even which hook is using it.



-- 
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]

Reply via email to