You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "hy144328 (via GitHub)" <gi...@apache.org> on 2026/07/10 01:43:18 UTC
[PR] refactor: Engine.execute() is deprecated. [superset]
hy144328 opened a new pull request, #41917:
URL: https://github.com/apache/superset/pull/41917
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563999873
##########
superset/db_engine_specs/doris.py:
##########
@@ -326,8 +327,9 @@ def get_catalog_names(
CatalogId, CatalogName, Type, IsCurrent, CreateTime, LastUpdateTime, Comment
We need to extract just the CatalogName column.
"""
- result = inspector.bind.execute(text("SHOW CATALOGS"))
- return {row.CatalogName for row in result}
+ with inspector.engine.connect() as conn:
+ result = conn.execute(text("SHOW CATALOGS"))
Review Comment:
Not a regression.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563999634
##########
scripts/benchmark_migration.py:
##########
@@ -153,10 +153,11 @@ def main( # noqa: C901
)
print(f"Migration goes from {down_revision} to {revision}")
- current_revision = db.engine.execute(
- text("SELECT version_num FROM alembic_version")
- ).scalar()
- print(f"Current version of the DB is {current_revision}")
+ with db.engine.connect() as conn:
+ current_revision = conn.execute(
+ text("SELECT version_num FROM alembic_version")
+ ).scalar()
Review Comment:
Not a regression.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563925709
##########
superset/db_engine_specs/snowflake.py:
##########
@@ -265,12 +265,13 @@ def get_catalog_names(
In Snowflake, a catalog is called a "database".
"""
- return {
- catalog
- for (catalog,) in inspector.bind.execute(
- text("SELECT DATABASE_NAME from information_schema.databases")
- )
- }
+ with inspector.bind.connect() as conn:
Review Comment:
Done.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563968029
##########
superset/db_engine_specs/hive.py:
##########
@@ -260,22 +261,23 @@ def _get_hive_type(dtype: np.dtype[Any]) -> str:
catalog=table.catalog,
schema=table.schema,
) as engine:
- engine.execute(
- text(
- f"""
- CREATE TABLE {str(table)} ({schema_definition})
- STORED AS PARQUET
- LOCATION :location
- """
- ),
- location=upload_to_s3(
- filename=file.name,
- upload_prefix=app.config["CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC"](
- database, g.user, table.schema
+ with engine.begin() as conn:
+ conn.execute(
+ text(
+ f"""
+ CREATE TABLE {str(table)} ({schema_definition})
+ STORED AS PARQUET
+ LOCATION :location
+ """
),
- table=table,
- ),
- )
+ location=upload_to_s3(
+ filename=file.name,
+ upload_prefix=app.config[
+ "CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC"
+ ](database, g.user, table.schema),
+ table=table,
+ ),
+ )
Review Comment:
Done.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: replace Engine.execute() with Connection.execute() [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #41917:
URL: https://github.com/apache/superset/pull/41917
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3555874842
##########
superset/cli/test_db.py:
##########
@@ -120,14 +120,16 @@ def test_datetime(console: Console, engine: Engine) -> None:
now = datetime.now()
console.print("Inserting timestamp value...")
- insert_stmt = insert(table).values(ts=now)
- engine.execute(insert_stmt)
+ with engine.begin() as conn:
+ insert_stmt = insert(table).values(ts=now)
Review Comment:
**Suggestion:** Add an explicit type annotation for this newly introduced SQL insert statement variable. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The added local variable `insert_stmt` is introduced without a type annotation, and its type can be annotated from the SQLAlchemy expression it stores. This matches the rule requiring type hints on relevant Python variables in new or modified code.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=42e024ea350f4a48a51485b7943e3de0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=42e024ea350f4a48a51485b7943e3de0&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/cli/test_db.py
**Line:** 124:124
**Comment:**
*Custom Rule: Add an explicit type annotation for this newly introduced SQL insert statement variable.
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=18cfcab4b81715a31f6f475c946253f58e2bd2bfba2a5f5afe0d5fea7cec3915&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=18cfcab4b81715a31f6f475c946253f58e2bd2bfba2a5f5afe0d5fea7cec3915&reaction=dislike'>π</a>
##########
superset/db_engine_specs/snowflake.py:
##########
@@ -265,12 +265,13 @@ def get_catalog_names(
In Snowflake, a catalog is called a "database".
"""
- return {
- catalog
- for (catalog,) in inspector.bind.execute(
- text("SELECT DATABASE_NAME from information_schema.databases")
- )
- }
+ with inspector.bind.connect() as conn:
Review Comment:
**Suggestion:** Add an explicit type annotation for the new connection variable so the updated method keeps full type coverage for introduced variables. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The new local variable `conn` is introduced in modified Python code without any type annotation. Under the stated rule, newly added variables that can be annotated should include type hints, so this is a real violation.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=fa21608e7d2f496fbdc472c85dd65e4b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=fa21608e7d2f496fbdc472c85dd65e4b&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/snowflake.py
**Line:** 268:268
**Comment:**
*Custom Rule: Add an explicit type annotation for the new connection variable so the updated method keeps full type coverage for introduced variables.
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=8190c9d8c69cf15371b420737392bcd5738e4b58c750dcf4b86bf8aff7499583&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=8190c9d8c69cf15371b420737392bcd5738e4b58c750dcf4b86bf8aff7499583&reaction=dislike'>π</a>
##########
superset/utils/mock_data.py:
##########
@@ -205,11 +205,12 @@ def add_data(
table = DBTable(table_name, metadata, *column_objects)
metadata.create_all(engine)
- if not append:
- engine.execute(table.delete())
+ with engine.begin() as conn:
+ if not append:
+ conn.execute(table.delete())
- data = generate_data(columns, num_rows)
- engine.execute(table.insert(), data)
+ data = generate_data(columns, num_rows)
Review Comment:
**Suggestion:** Add an explicit type annotation for the newly introduced `data` local variable so the generated payload type is declared. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The new local variable `data` is assigned a generated list payload without any type annotation, and it is a newly introduced variable in modified Python code that can be annotated, so this matches the type-hint rule.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9b7c6a9951a34f26a47cc29aaff8a4a5&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9b7c6a9951a34f26a47cc29aaff8a4a5&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/utils/mock_data.py
**Line:** 212:212
**Comment:**
*Custom Rule: Add an explicit type annotation for the newly introduced `data` local variable so the generated payload type is declared.
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=fb29a51b7bd12e1c1c8f90a03f06b56ffd6b89fcb290e11c01d8bbd04101e30c&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=fb29a51b7bd12e1c1c8f90a03f06b56ffd6b89fcb290e11c01d8bbd04101e30c&reaction=dislike'>π</a>
##########
tests/integration_tests/databases/commands/upload_test.py:
##########
@@ -114,12 +115,13 @@ def test_csv_upload_with_nulls():
CSVReader({"null_values": ["N/A", "None"]}),
).run()
with upload_database.get_sqla_engine() as engine:
- data = engine.execute(text(f"SELECT * from {CSV_UPLOAD_TABLE}")).fetchall() # noqa: S608
- assert data == [
- ("name1", None, "city1", "1-1-1980"),
- ("name2", 29, None, "1-1-1981"),
- ("name3", 28, "city3", "1-1-1982"),
- ]
+ with engine.connect() as conn:
+ data = conn.execute(text(f"SELECT * from {CSV_UPLOAD_TABLE}")).fetchall() # noqa: S608
Review Comment:
**Suggestion:** Add an explicit type annotation for the local query result variable so this newly introduced variable is type-hinted. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The new local variable `data` is introduced without any type annotation, and this file is Python code where a variable holding fetched rows can be annotated under the type-hint rule.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c1b68c3c0d274345b70ea522097341dc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=c1b68c3c0d274345b70ea522097341dc&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:** tests/integration_tests/databases/commands/upload_test.py
**Line:** 119:119
**Comment:**
*Custom Rule: Add an explicit type annotation for the local query result variable so this newly introduced variable is type-hinted.
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=1adf7700c5f9a3148a4938b37a0604c5ef4b8a65035ad0953e4c2a2e9637e1b2&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=1adf7700c5f9a3148a4938b37a0604c5ef4b8a65035ad0953e4c2a2e9637e1b2&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3555874052
##########
superset/db_engine_specs/starrocks.py:
##########
@@ -344,24 +344,25 @@ def get_catalog_names(
The command returns columns: Catalog, Type, Comment
"""
try:
- result = inspector.bind.execute(text("SHOW CATALOGS"))
- catalogs = set()
-
- for row in result:
- try:
- if hasattr(row, "keys") and "Catalog" in row.keys():
- catalogs.add(row["Catalog"])
- elif hasattr(row, "Catalog"):
- catalogs.add(row.Catalog)
- else:
- catalogs.add(row[0])
- except (AttributeError, TypeError, IndexError, KeyError) as ex:
- logger.warning(
- "Unable to extract catalog name from row: %s (%s)", row, ex
- )
- continue
-
- return catalogs
+ with inspector.engine.connect() as conn:
+ result = conn.execute(text("SHOW CATALOGS"))
+ catalogs = set()
Review Comment:
**Suggestion:** Add an explicit local type annotation for the catalog accumulator so its element type is clear and enforced. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The new local variable `catalogs` is introduced without an explicit type hint even though its element type can be annotated (for example, `set[str]`). This matches the rule requiring type hints on new or modified Python variables that can be annotated.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=036d26ec485140de9e776477c7a1c562&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=036d26ec485140de9e776477c7a1c562&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/starrocks.py
**Line:** 349:349
**Comment:**
*Custom Rule: Add an explicit local type annotation for the catalog accumulator so its element type is clear and enforced.
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=44cabe4190e0b091890c19f0b70ca1fb5833b1aff287e54d1de3dcf65dde01f8&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=44cabe4190e0b091890c19f0b70ca1fb5833b1aff287e54d1de3dcf65dde01f8&reaction=dislike'>π</a>
##########
superset/db_engine_specs/starrocks.py:
##########
@@ -375,8 +376,9 @@ def get_schema_names(cls, inspector: Inspector) -> set[str]:
(e.g., "catalog." sets the context to that catalog).
"""
try:
- result = inspector.bind.execute(text("SHOW DATABASES"))
- return {row[0] for row in result}
+ with inspector.engine.connect() as conn:
+ result = conn.execute(text("SHOW DATABASES"))
Review Comment:
**Suggestion:** Add an explicit type annotation for the query result variable to satisfy the type-hint requirement for new local variables. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The new local variable `result` is introduced without an explicit type annotation. Since the rule covers new Python variables that can be annotated, this is a real type-hint omission.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8786d6d4de5147418cb1224814f868ec&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8786d6d4de5147418cb1224814f868ec&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/starrocks.py
**Line:** 380:380
**Comment:**
*Custom Rule: Add an explicit type annotation for the query result variable to satisfy the type-hint requirement for new local variables.
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=85e8d54d2e126324ad218475f8af895f7a0081ca1fab1d22ab7608aea94b9512&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=85e8d54d2e126324ad218475f8af895f7a0081ca1fab1d22ab7608aea94b9512&reaction=dislike'>π</a>
##########
tests/integration_tests/conftest.py:
##########
@@ -146,15 +146,15 @@ def setup_sample_data() -> Any:
db.session.commit()
-def drop_from_schema(engine: Engine, schema_name: str):
- schemas = engine.execute(text("SHOW SCHEMAS")).fetchall() # noqa: F541
+def drop_from_schema(conn: Connection, schema_name: str):
Review Comment:
**Suggestion:** Add an explicit return type hint to this newly introduced function definition. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The new helper function is missing a return type annotation, which violates the Python type-hints rule for newly added or modified code.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9a21b9acfea64990afe42dab40481dff&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9a21b9acfea64990afe42dab40481dff&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:** tests/integration_tests/conftest.py
**Line:** 149:149
**Comment:**
*Custom Rule: Add an explicit return type hint to this newly introduced function definition.
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=a7773f3feb1c2bfbc99f54732bd1780bd2243443c3d726d0257f2aeda89e228c&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=a7773f3feb1c2bfbc99f54732bd1780bd2243443c3d726d0257f2aeda89e228c&reaction=dislike'>π</a>
##########
superset/db_engine_specs/doris.py:
##########
@@ -326,8 +327,9 @@ def get_catalog_names(
CatalogId, CatalogName, Type, IsCurrent, CreateTime, LastUpdateTime, Comment
We need to extract just the CatalogName column.
"""
- result = inspector.bind.execute(text("SHOW CATALOGS"))
- return {row.CatalogName for row in result}
+ with inspector.engine.connect() as conn:
+ result = conn.execute(text("SHOW CATALOGS"))
Review Comment:
**Suggestion:** Add an explicit type annotation for the newly introduced query result variable to satisfy the type-hint requirement for relevant variables. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The new local variable `result` is introduced in modified Python code without a type annotation, and it is the kind of relevant variable that can be annotated. This matches the type-hint requirement violation.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7f3c07ae71134786b54cc13dcbf7f647&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=7f3c07ae71134786b54cc13dcbf7f647&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:** 331:331
**Comment:**
*Custom Rule: Add an explicit type annotation for the newly introduced query result variable to satisfy the type-hint requirement for relevant variables.
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=2dabc6e2450be3c090edec893dcf68059e936d42206b31b4c4b97828b1880489&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=2dabc6e2450be3c090edec893dcf68059e936d42206b31b4c4b97828b1880489&reaction=dislike'>π</a>
##########
scripts/benchmark_migration.py:
##########
@@ -153,10 +153,11 @@ def main( # noqa: C901
)
print(f"Migration goes from {down_revision} to {revision}")
- current_revision = db.engine.execute(
- text("SELECT version_num FROM alembic_version")
- ).scalar()
- print(f"Current version of the DB is {current_revision}")
+ with db.engine.connect() as conn:
+ current_revision = conn.execute(
+ text("SELECT version_num FROM alembic_version")
+ ).scalar()
Review Comment:
**Suggestion:** Add an explicit type annotation for the newly introduced revision value variable to satisfy the type-hint requirement for relevant variables. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The new local variable `current_revision` is inferred from a database scalar result and has no explicit type annotation. This matches the Python type-hint rule for relevant variables that can be annotated.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f3746a7b0d6c4d7a9ec5b92ee67e9dec&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f3746a7b0d6c4d7a9ec5b92ee67e9dec&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:** scripts/benchmark_migration.py
**Line:** 156:159
**Comment:**
*Custom Rule: Add an explicit type annotation for the newly introduced revision value variable to satisfy the type-hint requirement for relevant variables.
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=3769a465e7b785fc99ead6aa0ce4d9e2bf09a044a7fbcb5c7858b7d72e2def1f&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=3769a465e7b785fc99ead6aa0ce4d9e2bf09a044a7fbcb5c7858b7d72e2def1f&reaction=dislike'>π</a>
##########
superset/db_engine_specs/impala.py:
##########
@@ -96,11 +96,12 @@ def convert_dttm(
@classmethod
def get_schema_names(cls, inspector: Inspector) -> set[str]:
- return {
- row[0]
- for row in inspector.engine.execute(text("SHOW SCHEMAS"))
- if not row[0].startswith("_")
- }
+ with inspector.engine.connect() as conn:
Review Comment:
**Suggestion:** Add an explicit type annotation for the new local connection variable by assigning the connection object to a typed variable before entering the context manager. [custom_rule]
**Severity Level:** Minor β οΈ
<details>
<summary><b>Why it matters? π€ </b></summary>
The new code introduces a local variable `conn` without any type annotation. The rule requires type hints for relevant variables that can be annotated, and this connection variable is a candidate for annotation.
</details>
<details>
<summary><b>Rule source π </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=833314d79062425791100a6673693c6c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=833314d79062425791100a6673693c6c&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/impala.py
**Line:** 99:99
**Comment:**
*Custom Rule: Add an explicit type annotation for the new local connection variable by assigning the connection object to a typed variable before entering the context manager.
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=749a018dc892f28ca53445020ed4a1c2441177bc43dbfad5ab4556f2ec3cd815&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=749a018dc892f28ca53445020ed4a1c2441177bc43dbfad5ab4556f2ec3cd815&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563925277
##########
tests/integration_tests/conftest.py:
##########
@@ -407,11 +409,12 @@ def physical_dataset():
yield dataset
- engine.execute(
- text("""
- DROP TABLE physical_dataset;
- """)
- )
+ with engine.begin() as conn:
Review Comment:
Done.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3564000866
##########
superset/cli/test_db.py:
##########
@@ -120,14 +120,16 @@ def test_datetime(console: Console, engine: Engine) -> None:
now = datetime.now()
console.print("Inserting timestamp value...")
- insert_stmt = insert(table).values(ts=now)
- engine.execute(insert_stmt)
+ with engine.begin() as conn:
+ insert_stmt = insert(table).values(ts=now)
Review Comment:
Not a regression.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #41917:
URL: https://github.com/apache/superset/pull/41917#issuecomment-4931219934
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/41917?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `0%` with `64 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 55.01%. Comparing base ([`1fd43ff`](https://app.codecov.io/gh/apache/superset/commit/1fd43ffe52c8ba01ae4246c0f94f95913e481787?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ee9ec50`](https://app.codecov.io/gh/apache/superset/commit/ee9ec500397856a217dd9392a78a38e5d2f47fae?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 3 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/41917?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/db\_engine\_specs/starrocks.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Fdb_engine_specs%2Fstarrocks.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL3N0YXJyb2Nrcy5weQ==) | 0.00% | [17 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/db\_engine\_specs/databricks.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Fdb_engine_specs%2Fdatabricks.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2RhdGFicmlja3MucHk=) | 0.00% | [9 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/cli/test\_db.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Fcli%2Ftest_db.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY2xpL3Rlc3RfZGIucHk=) | 0.00% | [8 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/db\_engine\_specs/doris.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Fdb_engine_specs%2Fdoris.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2RvcmlzLnB5) | 0.00% | [7 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/utils/mock\_data.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Futils%2Fmock_data.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdXRpbHMvbW9ja19kYXRhLnB5) | 0.00% | [7 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/db\_engine\_specs/hive.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Fdb_engine_specs%2Fhive.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2hpdmUucHk=) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/db\_engine\_specs/presto.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Fdb_engine_specs%2Fpresto.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL3ByZXN0by5weQ==) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/db\_engine\_specs/duckdb.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Fdb_engine_specs%2Fduckdb.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2R1Y2tkYi5weQ==) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/db\_engine\_specs/impala.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Fdb_engine_specs%2Fimpala.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2ltcGFsYS5weQ==) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/db\_engine\_specs/postgres.py](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&filepath=superset%2Fdb_engine_specs%2Fpostgres.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL3Bvc3RncmVzLnB5) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| ... and [1 more](https://app.codecov.io/gh/apache/superset/pull/41917?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
> :exclamation: There is a different number of reports uploaded between BASE (1fd43ff) and HEAD (ee9ec50). Click for more details.
>
> <details><summary>HEAD has 84 uploads less than BASE</summary>
>
>| Flag | BASE (1fd43ff) | HEAD (ee9ec50) |
>|------|------|------|
>|python|74|1|
>|hive|12|1|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #41917 +/- ##
==========================================
- Coverage 64.57% 55.01% -9.56%
==========================================
Files 2713 2718 +5
Lines 151269 151520 +251
Branches 34793 34808 +15
==========================================
- Hits 97684 83365 -14319
- Misses 51760 67738 +15978
+ Partials 1825 417 -1408
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/41917/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Ξ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/41917/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.05% <0.00%> (+0.04%)` | :arrow_up: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/41917/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/41917/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/41917/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/41917/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.05% <0.00%> (-19.85%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/41917/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/41917/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/41917?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3555895016
##########
superset/db_engine_specs/hive.py:
##########
@@ -260,22 +261,23 @@ def _get_hive_type(dtype: np.dtype[Any]) -> str:
catalog=table.catalog,
schema=table.schema,
) as engine:
- engine.execute(
- text(
- f"""
- CREATE TABLE {str(table)} ({schema_definition})
- STORED AS PARQUET
- LOCATION :location
- """
- ),
- location=upload_to_s3(
- filename=file.name,
- upload_prefix=app.config["CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC"](
- database, g.user, table.schema
+ with engine.begin() as conn:
+ conn.execute(
+ text(
+ f"""
+ CREATE TABLE {str(table)} ({schema_definition})
+ STORED AS PARQUET
+ LOCATION :location
+ """
),
- table=table,
- ),
- )
+ location=upload_to_s3(
+ filename=file.name,
+ upload_prefix=app.config[
+ "CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC"
+ ](database, g.user, table.schema),
+ table=table,
+ ),
+ )
Review Comment:
**Suggestion:** The parameter binding call uses a keyword argument in `Connection.execute`, which is not supported by SQLAlchemy 2-style execution and will raise a runtime argument error when this code runs on 2.x-compatible connections. Pass bind values as a single mapping/dict argument instead of `location=`. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major β οΈ</summary>
```mdx
- β Hive DataFrame uploads fail when replacing existing tables.
- β οΈ CSV upload UI errors on Hive replace strategy.
```
</details>
<details>
<summary><b>Steps of Reproduction β
</b></summary>
```mdx
1. Trigger a DataFrame upload to a Hive database via the upload command in
`superset/commands/database/uploaders/base.py:110-21`, choosing the βif table already
existsβ option as `"replace"` so `to_sql_kwargs["if_exists"]` becomes `"replace"` (line
8).
2. The upload command calls `database.db_engine_spec.df_to_sql(database, data_table, df,
to_sql_kwargs=...)` at `superset/commands/database/uploaders/base.py:15-20`, and for a
Hive backend `database.db_engine_spec` resolves to `HiveEngineSpec` (see
`superset/models/core.py:20-22` for engine spec resolution).
3. Inside `HiveEngineSpec.df_to_sql` in `superset/db_engine_specs/hive.py:181-81`, when
`to_sql_kwargs["if_exists"] == "replace"` (line 32) the code opens an engine and
transaction, then executes the CREATE TABLE statement with `conn.execute(text(...),
location=upload_to_s3(...))` at lines 65-81 (corresponding to diff lines 264-280).
4. On SQLAlchemy 2.x-style connections, calling `Connection.execute(...)` with keyword
bind parameters instead of a mapping can result in an argument error (e.g., unexpected
keyword `'location'`), causing the Hive table creation to fail and surfacing as a
`DatabaseUploadFailed` from the upload commandβs exception handling at
`superset/commands/database/uploaders/base.py:21-31`.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a8ff2af704a947ea8e5dce08fcaa3bab&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=a8ff2af704a947ea8e5dce08fcaa3bab&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/hive.py
**Line:** 264:280
**Comment:**
*Api Mismatch: The parameter binding call uses a keyword argument in `Connection.execute`, which is not supported by SQLAlchemy 2-style execution and will raise a runtime argument error when this code runs on 2.x-compatible connections. Pass bind values as a single mapping/dict argument instead of `location=`.
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=228570e3e5a2afc34c2a1906e1286cffe33afaf13a5c6222d707ed862abd79a2&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=228570e3e5a2afc34c2a1906e1286cffe33afaf13a5c6222d707ed862abd79a2&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
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>
[](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) [](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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3555889568
##########
tests/integration_tests/conftest.py:
##########
@@ -407,11 +409,12 @@ def physical_dataset():
yield dataset
- engine.execute(
- text("""
- DROP TABLE physical_dataset;
- """)
- )
+ with engine.begin() as conn:
+ conn.execute(
+ text("""
+ DROP TABLE physical_dataset;
+ """)
+ )
Review Comment:
**Suggestion:** The teardown block reuses `engine` after leaving `with example_database.get_sqla_engine() as engine:`. That context manager is responsible for connection lifecycle (including SSH tunnel cleanup), so using the same engine later can fail with closed/disposed resources. Open a fresh `get_sqla_engine()` context inside teardown before executing the drop statement. [stale reference]
<details>
<summary><b>Severity Level:</b> Major β οΈ</summary>
```mdx
- β physical_dataset teardown may fail on SSH-tunneled example_database.
- β οΈ Flaky failures in test_time_column_with_time_grain integration test.
```
</details>
<details>
<summary><b>Steps of Reproduction β
</b></summary>
```mdx
1. Run pytest for `test_time_column_with_time_grain` in
`tests/integration_tests/query_context_tests.py:1086`, which requests the
`physical_dataset` fixture defined in `tests/integration_tests/conftest.py:351-418` (PR
diff).
2. During fixture setup, `physical_dataset` calls `get_example_database()` and enters
`with example_database.get_sqla_engine() as engine:` at
`tests/integration_tests/conftest.py:357`. Inside this block, the table is created and
populated via `engine.begin()` while `Database.get_sqla_engine()`
(`superset/models/core.py:456-590`) manages SSH tunnels, engine context, and OAuth2.
3. After inserts, the `with example_database.get_sqla_engine() as engine:` context exits
before `yield dataset` at `tests/integration_tests/conftest.py:71-91`, unwinding
`Database.get_sqla_engine`βs internals: SSH tunnel context
(`superset/models/core.py:23-32`), engine context manager, and in some configurations
disposal of the private engine (`superset/models/core.py:25-37`).
4. Once the test function finishes and fixture teardown runs, code at
`tests/integration_tests/conftest.py:412-417` executes `with engine.begin() as conn:`
using the same `engine` object outside its managing context. If `example_database` is
configured with an SSH tunnel or prequeries, this teardown call tries to open a new
connection on a disposed engine and/or closed tunnel, leading to connection errors during
`DROP TABLE physical_dataset` and causing flaky failures in any tests that depend on
`physical_dataset`.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=291e6e55a4e84422805041aedaa2ca39&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=291e6e55a4e84422805041aedaa2ca39&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:** tests/integration_tests/conftest.py
**Line:** 412:417
**Comment:**
*Stale Reference: The teardown block reuses `engine` after leaving `with example_database.get_sqla_engine() as engine:`. That context manager is responsible for connection lifecycle (including SSH tunnel cleanup), so using the same engine later can fail with closed/disposed resources. Open a fresh `get_sqla_engine()` context inside teardown before executing the drop statement.
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=ed3029d95b4ae58f2ec57cfe843f98ff9e4145d04815f28550c1bc00368f33a8&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=ed3029d95b4ae58f2ec57cfe843f98ff9e4145d04815f28550c1bc00368f33a8&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3555908300
##########
tests/integration_tests/conftest.py:
##########
@@ -407,11 +409,12 @@ def physical_dataset():
yield dataset
- engine.execute(
- text("""
- DROP TABLE physical_dataset;
- """)
- )
+ with engine.begin() as conn:
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-674: Undefined Variable in Teardown</b></div>
<div id="fix">
The teardown code at line 412 references `engine`, but `engine` is defined inside a `with` block (lines 357-388) that exits before the `yield` statement at line 410. This causes `NameError: name 'engine' is not defined` when the fixture is torn down. (See also: [CWE-674](https://cwe.mitre.org/data/definitions/674.html))
</div>
</div>
<small><i>Code Review Run #73866c</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset/db_engine_specs/snowflake.py:
##########
@@ -265,12 +265,13 @@ def get_catalog_names(
In Snowflake, a catalog is called a "database".
"""
- return {
- catalog
- for (catalog,) in inspector.bind.execute(
- text("SELECT DATABASE_NAME from information_schema.databases")
- )
- }
+ with inspector.bind.connect() as conn:
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Invalid attribute on Inspector</b></div>
<div id="fix">
Line 268 uses `inspector.bind.connect()` but SQLAlchemy's `Inspector` class only has an `engine` attribute, not `bind`. This will raise `AttributeError: 'Inspector' object has no attribute 'bind'` at runtime. All other engine specs (postgres, presto, databricks, etc.) consistently use `inspector.engine.connect()` as seen in postgres.py:785.
</div>
</div>
<small><i>Code Review Run #73866c</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41917:
URL: https://github.com/apache/superset/pull/41917#issuecomment-4931201398
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563925956
##########
superset/db_engine_specs/snowflake.py:
##########
@@ -265,12 +265,13 @@ def get_catalog_names(
In Snowflake, a catalog is called a "database".
"""
- return {
- catalog
- for (catalog,) in inspector.bind.execute(
- text("SELECT DATABASE_NAME from information_schema.databases")
- )
- }
+ with inspector.bind.connect() as conn:
Review Comment:
<!-- Bito Reply -->
The suggestion to use `inspector.engine.connect()` instead of `inspector.bind.connect()` is correct. The `Inspector` class in SQLAlchemy does not have a `bind` attribute, and using `engine` is the standard approach for accessing the connection, as seen in other engine specifications.
**superset/db_engine_specs/snowflake.py**
```
with inspector.engine.connect() as conn:
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563954542
##########
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:
Done.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3564001716
##########
superset/utils/mock_data.py:
##########
@@ -205,11 +205,12 @@ def add_data(
table = DBTable(table_name, metadata, *column_objects)
metadata.create_all(engine)
- if not append:
- engine.execute(table.delete())
+ with engine.begin() as conn:
+ if not append:
+ conn.execute(table.delete())
- data = generate_data(columns, num_rows)
- engine.execute(table.insert(), data)
+ data = generate_data(columns, num_rows)
Review Comment:
Not a regression.
##########
tests/integration_tests/databases/commands/upload_test.py:
##########
@@ -114,12 +115,13 @@ def test_csv_upload_with_nulls():
CSVReader({"null_values": ["N/A", "None"]}),
).run()
with upload_database.get_sqla_engine() as engine:
- data = engine.execute(text(f"SELECT * from {CSV_UPLOAD_TABLE}")).fetchall() # noqa: S608
- assert data == [
- ("name1", None, "city1", "1-1-1980"),
- ("name2", 29, None, "1-1-1981"),
- ("name3", 28, "city3", "1-1-1982"),
- ]
+ with engine.connect() as conn:
+ data = conn.execute(text(f"SELECT * from {CSV_UPLOAD_TABLE}")).fetchall() # noqa: S608
Review Comment:
Not a regression.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563998130
##########
superset/db_engine_specs/starrocks.py:
##########
@@ -344,24 +344,25 @@ def get_catalog_names(
The command returns columns: Catalog, Type, Comment
"""
try:
- result = inspector.bind.execute(text("SHOW CATALOGS"))
- catalogs = set()
-
- for row in result:
- try:
- if hasattr(row, "keys") and "Catalog" in row.keys():
- catalogs.add(row["Catalog"])
- elif hasattr(row, "Catalog"):
- catalogs.add(row.Catalog)
- else:
- catalogs.add(row[0])
- except (AttributeError, TypeError, IndexError, KeyError) as ex:
- logger.warning(
- "Unable to extract catalog name from row: %s (%s)", row, ex
- )
- continue
-
- return catalogs
+ with inspector.engine.connect() as conn:
+ result = conn.execute(text("SHOW CATALOGS"))
+ catalogs = set()
Review Comment:
Not a regression.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3564000294
##########
superset/db_engine_specs/impala.py:
##########
@@ -96,11 +96,12 @@ def convert_dttm(
@classmethod
def get_schema_names(cls, inspector: Inspector) -> set[str]:
- return {
- row[0]
- for row in inspector.engine.execute(text("SHOW SCHEMAS"))
- if not row[0].startswith("_")
- }
+ with inspector.engine.connect() as conn:
Review Comment:
Not a regression.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563999194
##########
tests/integration_tests/conftest.py:
##########
@@ -146,15 +146,15 @@ def setup_sample_data() -> Any:
db.session.commit()
-def drop_from_schema(engine: Engine, schema_name: str):
- schemas = engine.execute(text("SHOW SCHEMAS")).fetchall() # noqa: F541
+def drop_from_schema(conn: Connection, schema_name: str):
Review Comment:
Not a regression.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563953921
##########
tests/integration_tests/datasets/commands_tests.py:
##########
@@ -279,8 +279,9 @@ def test_export_dataset_command_unicode_chars(self, mock_g) -> None:
mock_g.user = security_manager.find_user("admin")
examples_db = get_example_database()
with examples_db.get_sqla_engine() as engine:
- engine.execute("DROP TABLE IF EXISTS δΈζ")
- engine.execute("CREATE TABLE δΈζ AS SELECT 2 as col")
+ with engine.begin() as conn:
+ conn.execute("DROP TABLE IF EXISTS δΈζ")
+ conn.execute("CREATE TABLE δΈζ AS SELECT 2 as col")
Review Comment:
Done.
##########
tests/integration_tests/datasets/commands_tests.py:
##########
@@ -307,7 +308,8 @@ def test_export_dataset_command_unicode_chars(self, mock_g) -> None:
db.session.delete(example_dataset)
db.session.commit()
with examples_db.get_sqla_engine() as engine:
- engine.execute("DROP TABLE δΈζ")
+ with engine.begin() as conn:
+ conn.execute("DROP TABLE δΈζ")
Review Comment:
Done.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #41917:
URL: https://github.com/apache/superset/pull/41917#issuecomment-4931207859
### <span aria-hidden="true">β
</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">π¨</span> Latest commit | ee9ec500397856a217dd9392a78a38e5d2f47fae |
|<span aria-hidden="true">π</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a504e3615d9de000848eb6d |
|<span aria-hidden="true">π</span> Deploy Preview | [https://deploy-preview-41917--superset-docs-preview.netlify.app](https://deploy-preview-41917--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">π±</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">π€</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DctNDoIwEAbQu8zahhqhQW_gMYbOJzTpn2NJJMa7093bvB9VLak2ehBdaFHOfutWvNi3osPnHTn6DekwKazKLZRskNeQYfCF3xv6E9RYjqf06XiyI27uOsldYK2dxxmLE_qf) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-41917--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3555885830
##########
tests/integration_tests/datasets/commands_tests.py:
##########
@@ -279,8 +279,9 @@ def test_export_dataset_command_unicode_chars(self, mock_g) -> None:
mock_g.user = security_manager.find_user("admin")
examples_db = get_example_database()
with examples_db.get_sqla_engine() as engine:
- engine.execute("DROP TABLE IF EXISTS δΈζ")
- engine.execute("CREATE TABLE δΈζ AS SELECT 2 as col")
+ with engine.begin() as conn:
+ conn.execute("DROP TABLE IF EXISTS δΈζ")
+ conn.execute("CREATE TABLE δΈζ AS SELECT 2 as col")
Review Comment:
**Suggestion:** `Connection.execute()` in SQLAlchemy 2.x does not accept raw SQL strings, so these setup statements will raise `ObjectNotExecutableError` at runtime and the test will fail before reaching the command assertions. Wrap the SQL in `text(...)` (or use `exec_driver_sql`) for both statements. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major β οΈ</summary>
```mdx
- β test_export_dataset_command_unicode_chars fails at setup.
- β οΈ ExportDatasetsCommand unicode handling unvalidated in CI.
```
</details>
<details>
<summary><b>Steps of Reproduction β
</b></summary>
```mdx
1. Run the integration test suite, including `test_export_dataset_command_unicode_chars`
in `tests/integration_tests/datasets/commands_tests.py:18-55` (verified via Read tool).
2. Inside this test, `examples_db = get_example_database()` is called and
`examples_db.get_sqla_engine()` creates an SQLAlchemy engine context at
`commands_tests.py:21-22`.
3. The inner context `with engine.begin() as conn:` at `commands_tests.py:23` opens a
SQLAlchemy 2.x `Connection`, which then calls `conn.execute("DROP TABLE IF EXISTS δΈζ")`
and `conn.execute("CREATE TABLE δΈζ AS SELECT 2 as col")` at hunk lines 283-284 using plain
strings.
4. Under SQLAlchemy 2.x semantics, `Connection.execute()` requires an executable object
(e.g. `text(...)`); passing a bare string raises `ObjectNotExecutableError`, causing the
test to fail during setup before reaching the `ExportDatasetsCommand` run and assertions
at `commands_tests.py:41-47`.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=700dd2df241d4530887024ee0292dd92&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=700dd2df241d4530887024ee0292dd92&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:** tests/integration_tests/datasets/commands_tests.py
**Line:** 283:284
**Comment:**
*Api Mismatch: `Connection.execute()` in SQLAlchemy 2.x does not accept raw SQL strings, so these setup statements will raise `ObjectNotExecutableError` at runtime and the test will fail before reaching the command assertions. Wrap the SQL in `text(...)` (or use `exec_driver_sql`) for both statements.
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=b7c8bcd3ceaf97d3dd3df1a4b4bf53ced2f9294717f7601056ee93a0d9adb7cf&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=b7c8bcd3ceaf97d3dd3df1a4b4bf53ced2f9294717f7601056ee93a0d9adb7cf&reaction=dislike'>π</a>
##########
tests/integration_tests/datasets/commands_tests.py:
##########
@@ -307,7 +308,8 @@ def test_export_dataset_command_unicode_chars(self, mock_g) -> None:
db.session.delete(example_dataset)
db.session.commit()
with examples_db.get_sqla_engine() as engine:
- engine.execute("DROP TABLE δΈζ")
+ with engine.begin() as conn:
+ conn.execute("DROP TABLE δΈζ")
Review Comment:
**Suggestion:** This cleanup statement also uses a raw string with `Connection.execute()`, which can raise `ObjectNotExecutableError` and break test teardown. Use an executable SQL object (for example `text(...)`) or `exec_driver_sql` so teardown always runs. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major β οΈ</summary>
```mdx
- β Teardown in test_export_dataset_command_unicode_chars crashes.
- β οΈ Example database retains temporary table δΈζ between tests.
```
</details>
<details>
<summary><b>Steps of Reproduction β
</b></summary>
```mdx
1. Run `test_export_dataset_command_unicode_chars` in
`tests/integration_tests/datasets/commands_tests.py:18-55` as part of the integration
tests (function location verified via Read tool).
2. After creating and exporting the dataset, the test performs cleanup:
`db.session.delete(example_dataset)` and `db.session.commit()` at
`commands_tests.py:49-50`.
3. The test then opens a new engine context with `examples_db.get_sqla_engine()` and
`engine.begin()` at `commands_tests.py:51-53`, calling `conn.execute("DROP TABLE δΈζ")` at
hunk line 312 with a plain SQL string.
4. In SQLAlchemy 2.x, `Connection.execute()` with a bare string raises
`ObjectNotExecutableError`, so the teardown block crashes, potentially leaving the `δΈζ`
table undeleted in the example database and causing the test to fail during cleanup.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f9855f4cf1344dbdb4287940891a3b79&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f9855f4cf1344dbdb4287940891a3b79&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:** tests/integration_tests/datasets/commands_tests.py
**Line:** 312:312
**Comment:**
*Api Mismatch: This cleanup statement also uses a raw string with `Connection.execute()`, which can raise `ObjectNotExecutableError` and break test teardown. Use an executable SQL object (for example `text(...)`) or `exec_driver_sql` so teardown always runs.
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=6065b1638d2d369d58850df6042dbc75c67c425a80c7cc20304f927155357663&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=6065b1638d2d369d58850df6042dbc75c67c425a80c7cc20304f927155357663&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: replace Engine.execute() with Connection.execute() [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41917:
URL: https://github.com/apache/superset/pull/41917#issuecomment-4946884610
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563926597
##########
tests/integration_tests/conftest.py:
##########
@@ -407,11 +409,12 @@ def physical_dataset():
yield dataset
- engine.execute(
- text("""
- DROP TABLE physical_dataset;
- """)
- )
+ with engine.begin() as conn:
+ conn.execute(
+ text("""
+ DROP TABLE physical_dataset;
+ """)
+ )
Review Comment:
Done.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3563998457
##########
superset/db_engine_specs/starrocks.py:
##########
@@ -375,8 +376,9 @@ def get_schema_names(cls, inspector: Inspector) -> set[str]:
(e.g., "catalog." sets the context to that catalog).
"""
try:
- result = inspector.bind.execute(text("SHOW DATABASES"))
- return {row[0] for row in result}
+ with inspector.engine.connect() as conn:
+ result = conn.execute(text("SHOW DATABASES"))
Review Comment:
Not a regression.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Engine.execute() is deprecated. [superset]
Posted by "hy144328 (via GitHub)" <gi...@apache.org>.
hy144328 commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3564001332
##########
superset/db_engine_specs/snowflake.py:
##########
@@ -265,12 +265,13 @@ def get_catalog_names(
In Snowflake, a catalog is called a "database".
"""
- return {
- catalog
- for (catalog,) in inspector.bind.execute(
- text("SELECT DATABASE_NAME from information_schema.databases")
- )
- }
+ with inspector.bind.connect() as conn:
Review Comment:
Not a regression.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org