codeant-ai-for-open-source[bot] commented on code in PR #42739:
URL: https://github.com/apache/superset/pull/42739#discussion_r3741279822
##########
superset/commands/streaming_export/base.py:
##########
@@ -223,13 +223,27 @@ def _execute_query_and_stream(
# Merge database to prevent DetachedInstanceError
merged_database = session.merge(database)
+ # `is_split=True` mirrors the non-streaming download path exactly:
+ # Database.get_df() -> _execute_sql_with_mutation_and_logging()
+ # always calls mutate_sql_based_on_config(..., is_split=True) on
+ # SQL Lab's stored select_sql/executed_sql, and the chart query
+ # path applies its own mutation upstream (in
+ # get_query_str_extended, with is_split=False) before landing
+ # here. Since `is_split` and `MUTATE_AFTER_SPLIT` are compared
+ # for equality, `is_split=True` is the complement of that
+ # upstream chart mutation -- together they mutate the SQL
+ # exactly once for either MUTATE_AFTER_SPLIT setting, instead of
+ # double-mutating when it's False and never mutating when it's
+ # True.
+ mutated_sql = merged_database.mutate_sql_based_on_config(sql,
is_split=True)
Review Comment:
**Suggestion:** SQL Lab's `executed_sql` is already mutated during query
execution with `is_split=True` when `MUTATE_AFTER_SPLIT=True`. Applying the
mutator again here with the same flag double-mutates the stored SQL, so
non-idempotent mutators can duplicate comments, hints, or other transformations
before the export runs. Avoid re-mutating SQL Lab's already-executed SQL, or
pass sufficient execution-state information to ensure the mutator is applied
exactly once. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ SQL Lab streaming exports can execute doubly transformed SQL.
- ⚠️ Non-idempotent mutators can invalidate export queries.
- ⚠️ Query hints or comments may be duplicated unexpectedly.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7b36f6b480d04695a8d90842edc804b0&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=7b36f6b480d04695a8d90842edc804b0&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/commands/streaming_export/base.py
**Line:** 238:238
**Comment:**
*Api Mismatch: SQL Lab's `executed_sql` is already mutated during query
execution with `is_split=True` when `MUTATE_AFTER_SPLIT=True`. Applying the
mutator again here with the same flag double-mutates the stored SQL, so
non-idempotent mutators can duplicate comments, hints, or other transformations
before the export runs. Avoid re-mutating SQL Lab's already-executed SQL, or
pass sufficient execution-state information to ensure the mutator is applied
exactly once.
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%2F42739&comment_hash=c81768e9b249d356dbb75ebe3c34a5f7380306b43bee2df718d881dad1421c2d&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42739&comment_hash=c81768e9b249d356dbb75ebe3c34a5f7380306b43bee2df718d881dad1421c2d&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]