codeant-ai-for-open-source[bot] commented on code in PR #38174: URL: https://github.com/apache/superset/pull/38174#discussion_r2839033135
########## superset/db_engine_specs/odps.py: ########## @@ -0,0 +1,191 @@ +# 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 + +import logging +from typing import Any, Optional, TYPE_CHECKING + +from sqlalchemy import select, text +from sqlalchemy.engine.base import Engine + +from superset.databases.schemas import ( + TableMetadataColumnsResponse, + TableMetadataResponse, +) +from superset.databases.utils import ( + get_col_type, + get_foreign_keys_metadata, + get_indexes_metadata, +) +from superset.db_engine_specs.base import BaseEngineSpec, BasicParametersMixin +from superset.sql.parse import Partition, SQLScript +from superset.sql_parse import Table Review Comment: **Suggestion:** The module incorrectly imports `Table` from `superset.sql_parse`, which does not exist, causing an `ImportError` when loading the ODPS engine spec; `Table` should be imported from `superset.sql.parse` along with `Partition` and `SQLScript`. [logic error] <details> <summary><b>Severity Level:</b> Critical 🚨</summary> ```mdx - ❌ DatabaseRestApi import fails, breaking database REST endpoints. - ❌ ODPS engine spec unavailable for SQLLab table metadata. - ⚠️ Any feature importing OdpsEngineSpec crashes on startup. ``` </details> ```suggestion from superset.sql.parse import Partition, SQLScript, Table ``` <details> <summary><b>Steps of Reproduction ✅ </b></summary> ```mdx 1. Start the Superset application or any context that imports the database REST API; this imports `superset/databases/api.py` (see file header and imports at `superset/databases/api.py:1-115`). 2. `DatabaseRestApi` imports the ODPS engine spec via `from superset.db_engine_specs.odps import OdpsEngineSpec` at `superset/databases/api.py:114`. 3. Python loads `superset/db_engine_specs/odps.py`, executing its top-level imports, including `from superset.sql_parse import Table` at `superset/db_engine_specs/odps.py:35-36`. 4. Since there is no `superset/sql_parse.py` module on disk (confirmed by the missing file error when reading `/workspace/superset/superset/sql_parse.py` and the actual `Table` dataclass being defined in `superset/sql/parse.py:282-291`), module import fails with `ModuleNotFoundError: No module named 'superset.sql_parse'`, preventing `DatabaseRestApi` (and thus `/api/v1/database/*` endpoints and ODPS support) from loading. ``` </details> <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/db_engine_specs/odps.py **Line:** 35:36 **Comment:** *Logic Error: The module incorrectly imports `Table` from `superset.sql_parse`, which does not exist, causing an `ImportError` when loading the ODPS engine spec; `Table` should be imported from `superset.sql.parse` along with `Partition` and `SQLScript`. 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. ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38174&comment_hash=8a4f4b6cbb974f383de6730499de561bdf19b4a931cdd05795012d6edf4f8a30&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38174&comment_hash=8a4f4b6cbb974f383de6730499de561bdf19b4a931cdd05795012d6edf4f8a30&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]
