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


##########
superset/db_engine_specs/doris.py:
##########
@@ -307,9 +307,10 @@ def get_default_catalog(cls, database: Database) -> str:
 
         # if not, iterate over existing catalogs and find the current one
         with database.get_sqla_engine() as engine:
-            for catalog in engine.execute("SHOW CATALOGS"):
-                if catalog.IsCurrent:
-                    return catalog.CatalogName
+            with engine.connect() as conn:
+                for catalog in conn.execute("SHOW CATALOGS"):

Review Comment:
   **Suggestion:** The new call uses `Connection.execute()` with a plain SQL 
string, but SQLAlchemy 2.x requires an executable object (for example 
`text(...)`) and will raise `ObjectNotExecutableError` at runtime. Wrap this 
statement in `text("SHOW CATALOGS")` (or use `exec_driver_sql`) so default 
catalog detection does not fail. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Doris SQL Lab queries fail resolving default catalog.
   - ❌ Doris dataset uniqueness checks crash during catalog lookup.
   - ⚠️ Doris catalog-aware security checks may not execute.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure a Doris database in Superset with an SQLAlchemy URI whose 
`database`
   component does not contain a dot (e.g. `doris://host:9030/db`), so
   `database.url_object.database` lacks `.` and 
`DorisEngineSpec.get_default_catalog` in
   `superset/db_engine_specs/doris.py:21-29` does not take the early return.
   
   2. Execute a SQL Lab query against this Doris database without specifying a 
catalog in
   options; the SQL execution pipeline in 
`superset/sql/execution/executor.py:20-33` computes
   `catalog = opts.catalog or self.database.get_default_catalog()`, calling
   `Database.get_default_catalog()` on the Doris-backed `Database` object.
   
   3. Inside `Database.get_default_catalog()` in 
`superset/models/core.py:12-16`, Superset
   delegates to `self.db_engine_spec.get_default_catalog(self)`, which for 
Doris runs the
   code block at `superset/db_engine_specs/doris.py:29-35`, opening an engine 
and connection
   and then executing `for catalog in conn.execute("SHOW CATALOGS"):` (line 311 
in the PR
   hunk).
   
   4. Under SQLAlchemy 2.x, `Connection.execute()` no longer accepts a plain 
string, so
   `conn.execute("SHOW CATALOGS")` raises 
`sqlalchemy.exc.ObjectNotExecutableError` at
   runtime, causing the Doris SQL Lab query (and any other path that needs the 
default
   catalog, such as dataset uniqueness checks in 
`superset/daos/dataset.py:9-12`) to fail
   instead of discovering the current catalog.
   ```
   </details>
   
   [![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=71a4a23be5ca428e83072e1f42062709&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=71a4a23be5ca428e83072e1f42062709&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/db_engine_specs/doris.py
   **Line:** 311:311
   **Comment:**
        *Api Mismatch: The new call uses `Connection.execute()` with a plain 
SQL string, but SQLAlchemy 2.x requires an executable object (for example 
`text(...)`) and will raise `ObjectNotExecutableError` at runtime. Wrap this 
statement in `text("SHOW CATALOGS")` (or use `exec_driver_sql`) so default 
catalog detection does not fail.
   
   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%2F41917&comment_hash=799081bf657d688c491bea25c23d59772fb0896dbc25f0ef9d2dbdfe5dbb090f&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=799081bf657d688c491bea25c23d59772fb0896dbc25f0ef9d2dbdfe5dbb090f&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