codeant-ai-for-open-source[bot] commented on code in PR #44825:
URL: https://github.com/apache/superset/pull/44825#discussion_r4145899764


##########
superset/db_engine_specs/redshift.py:
##########
@@ -253,6 +262,51 @@ class RedshiftEngineSpec(BasicParametersMixin, 
PostgresBaseEngineSpec):
         ),
     }
 
+    @classmethod
+    def adjust_engine_params(
+        cls,
+        uri: URL,
+        connect_args: dict[str, Any],
+        catalog: str | None = None,
+        schema: str | None = None,
+    ) -> tuple[URL, dict[str, Any]]:
+        """
+        Set the catalog (database).
+        """
+        if catalog:
+            uri = uri.set(database=catalog)
+            # IAM connections pass the database in connect_args instead
+            if "database" in connect_args:
+                connect_args["database"] = catalog
+
+        return uri, connect_args
+
+    @classmethod
+    def get_default_catalog(cls, database: Database) -> str | None:
+        """
+        Return the default catalog for a given database.
+        """
+        return database.url_object.database

Review Comment:
   **Suggestion:** `get_default_catalog` ignores IAM's 
`connect_args["database"]`, so migrations skip those databases and leave 
existing permissions and model catalog fields unconverted.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes` ยท ๐Ÿท๏ธ `Api mismatch`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=971c99ce5ff14227ac623cafe8541d4e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=971c99ce5ff14227ac623cafe8541d4e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/db_engine_specs/redshift.py
   **Line:** 285:289
   **Comment:**
        *Api Mismatch: `get_default_catalog` ignores IAM's 
`connect_args["database"]`, so migrations skip those databases and leave 
existing permissions and model catalog fields unconverted.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44825&comment_hash=4220b6e3dd9c775aeea180096e97c05655d35ebe72e0181b7ef12b76dd8bcd16&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44825&comment_hash=4220b6e3dd9c775aeea180096e97c05655d35ebe72e0181b7ef12b76dd8bcd16&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/db_engine_specs/redshift.py:
##########
@@ -253,6 +262,51 @@ class RedshiftEngineSpec(BasicParametersMixin, 
PostgresBaseEngineSpec):
         ),
     }
 
+    @classmethod
+    def adjust_engine_params(
+        cls,
+        uri: URL,
+        connect_args: dict[str, Any],
+        catalog: str | None = None,
+        schema: str | None = None,
+    ) -> tuple[URL, dict[str, Any]]:
+        """
+        Set the catalog (database).
+        """
+        if catalog:
+            uri = uri.set(database=catalog)
+            # IAM connections pass the database in connect_args instead
+            if "database" in connect_args:
+                connect_args["database"] = catalog
+
+        return uri, connect_args
+
+    @classmethod
+    def get_default_catalog(cls, database: Database) -> str | None:
+        """
+        Return the default catalog for a given database.
+        """
+        return database.url_object.database
+
+    @classmethod
+    def get_catalog_names(
+        cls,
+        database: Database,
+        inspector: Inspector,
+    ) -> set[str]:
+        """
+        Return all catalogs.
+
+        In Redshift, a catalog is called a "database". SVV_REDSHIFT_DATABASES
+        also lists databases created from datashares, which pg_database does 
not.
+        """
+        return {
+            catalog
+            for (catalog,) in inspector.bind.execute(
+                sa.text("SELECT database_name FROM svv_redshift_databases")
+            )
+        }

Review Comment:
   **Suggestion:** `inspector.bind` is an Engine in SQLAlchemy 2, which has no 
`execute`; catalog discovery raises `AttributeError` for Redshift connections.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Often` ยท ๐Ÿท๏ธ `Api mismatch`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=bf35d951ac684ee8a3ee5c2e362958d1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=bf35d951ac684ee8a3ee5c2e362958d1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/db_engine_specs/redshift.py
   **Line:** 303:308
   **Comment:**
        *Api Mismatch: `inspector.bind` is an Engine in SQLAlchemy 2, which has 
no `execute`; catalog discovery raises `AttributeError` for Redshift 
connections.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44825&comment_hash=0d53c5e4d88dae2e961aced958a073707b3d7fccac4f8cdcfaf638fadfbd2760&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44825&comment_hash=0d53c5e4d88dae2e961aced958a073707b3d7fccac4f8cdcfaf638fadfbd2760&reaction=dislike'>๐Ÿ‘Ž</a>



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to