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


##########
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:
   Hello Jarek, I understand the issue with this approach and I also wasn't 
very happy with it but I wonder where I should put it then?  In the OdbcHook as 
we are using Hana with Odbc?  I'm not sure as that one should normally also not 
be aware of this implementation.  Should I create a HanaHook then?  But how 
does it then get loaded when we are using Odbc?  Any help would be appreciated 
so I can fix this correctly :)



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