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


##########
providers/ibm/db2/src/airflow/providers/ibm/db2/dialects/db2.py:
##########
@@ -0,0 +1,141 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from airflow.providers.common.sql.dialects.dialect import Dialect
+
+
+class Db2Dialect(Dialect):
+    """
+    Db2-specific SQL dialect implementation.
+
+    Provides Db2-specific SQL generation, particularly for MERGE (upsert) 
operations.
+    """
+
+    def get_column_names(
+        self,
+        table: str,
+        schema: str | None = None,
+        **kwargs,
+    ) -> list[str] | None:
+        """
+        Return column names for a table, excluding identity columns.
+
+        Db2 marks auto-generated identity columns with ``autoincrement=True`` 
in the
+        SQLAlchemy reflection result.  Excluding them here mirrors the 
hook-level
+        behaviour that was previously implemented on ``Db2Hook``, and 
delegates the
+        actual inspector call to the base ``Dialect.get_column_names`` 
predicate API.
+
+        :param table: Table name (may include schema prefix as 
``schema.table``)
+        :param schema: Optional schema name; takes precedence over a schema 
prefix in *table*
+        :return: Column names with identity (autoincrement) columns removed
+        """
+        return super().get_column_names(
+            table,
+            schema,
+            predicate=lambda col: not col.get("autoincrement", False),
+        )
+
+    def get_primary_keys(self, table: str, schema: str | None = None) -> 
list[str] | None:

Review Comment:
   Not sure if this is still needed as it doesn't do anything special related 
to DB2 as opposed to it's `get_column_names `method except the docstring, so I 
would personally remove 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