sohailshk commented on code in PR #76962:
URL: https://github.com/apache/airflow/pull/76962#discussion_r4553246478


##########
providers/postgres/src/airflow/providers/postgres/dialects/postgres.py:
##########
@@ -51,7 +51,7 @@ def get_primary_keys(self, table: str, schema: str | None = 
None) -> list[str] |
                             and kcu.constraint_schema = tco.constraint_schema
                             and kcu.constraint_name = tco.constraint_name
             where tco.constraint_type = 'PRIMARY KEY'
-            and kcu.table_schema = %s
+            and kcu.table_schema = coalesce(%s, current_schema())

Review Comment:
   current_schema() is the first schema on the search_path that exists, not the 
schema an unqualified table name points to.
   It was reproduced on Postgres 18 with a login role airflow that has its own 
airflow schema while the table is in public: the old query found no primary 
key, their query finds id.



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