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


##########
superset/config.py:
##########
@@ -2005,6 +2005,9 @@ def SQL_QUERY_MUTATOR(  # pylint: 
disable=invalid-name,unused-argument  # noqa:
 # An example use case is if data has role based access controls, and you want 
to apply
 # a SET ROLE statement alongside every user query. Changing this variable 
maintains
 # functionality for both the SQL_Lab and Charts.
+# This applies consistently in SQL Lab: with MUTATE_AFTER_SPLIT = True the 
mutator runs
+# on each individual statement, and with MUTATE_AFTER_SPLIT = False it runs 
once on the
+# un-split query block.

Review Comment:
   **Suggestion:** The new config comment overstates behavior and is incorrect 
for engines that run multiple statements as one block. With 
`MUTATE_AFTER_SPLIT=True`, the mutator does not run per statement in that mode, 
so this guidance can lead operators to misconfigure governance assumptions. 
Update the comment to mention the `run_multiple_statements_as_one` exception 
explicitly. [comment mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Minor ๐Ÿงน</summary>
   
   ```mdx
   - โš ๏ธ Config comment misrepresents behavior for single-block engines.
   - โš ๏ธ Operators may misconfigure SQL_QUERY_MUTATOR expectations.
   - โš ๏ธ Confusing behavior for SQL Lab governance setups.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction โœ… </b></summary>
   
   ```mdx
   1. Start Superset with this PR code and open `superset/config.py`, noting 
the comment at
   lines 2008โ€“2010 describing `MUTATE_AFTER_SPLIT` behavior: it claims the 
mutator runs on
   each individual statement when `MUTATE_AFTER_SPLIT = True`, and once on the 
un-split block
   when `MUTATE_AFTER_SPLIT = False`.
   
   2. Configure a database whose engine spec sets 
`run_multiple_statements_as_one = True`;
   these are the engines referenced in 
`superset/sql/execution/celery_task.py:136โ€“145` where
   the comment mentions databases like BigQuery and Kusto that are run as a 
single block.
   
   3. Set `MUTATE_AFTER_SPLIT = True` in `superset/config.py:2011` based on the 
guidance in
   the comment, and define a `SQL_QUERY_MUTATOR` that should apply governance 
logic per
   statement (for example, inject `SET ROLE <user>` before each statement).
   
   4. Execute a multi-statement SQL Lab query asynchronously so it goes through
   `execute_sql_task()` โ†’ `_execute_sql_statements()`
   (`superset/sql/execution/celery_task.py:367, 453`) โ†’ 
`_prepare_statement_blocks()`
   (`superset/sql/execution/celery_task.py:128`) which, because
   `run_multiple_statements_as_one = True`, builds a single `blocks` entry and 
calls
   `execute_sql_with_cursor()` with `is_split = False` at line 493; this means
   `Database.mutate_sql_based_on_config()` never sees `is_split == 
MUTATE_AFTER_SPLIT` when
   `MUTATE_AFTER_SPLIT = True`, so the mutator does not run per statement 
(indeed, it may not
   run at all), contradicting the configuration comment for these engines.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=798f0899e2724190b586b2e2ea103591&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=798f0899e2724190b586b2e2ea103591&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/config.py
   **Line:** 2008:2010
   **Comment:**
        *Comment Mismatch: The new config comment overstates behavior and is 
incorrect for engines that run multiple statements as one block. With 
`MUTATE_AFTER_SPLIT=True`, the mutator does not run per statement in that mode, 
so this guidance can lead operators to misconfigure governance assumptions. 
Update the comment to mention the `run_multiple_statements_as_one` exception 
explicitly.
   
   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%2F41127&comment_hash=371394279d501474b61c8db4af8242a7bf903a32c1163e9110f2c9cc51af0637&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41127&comment_hash=371394279d501474b61c8db4af8242a7bf903a32c1163e9110f2c9cc51af0637&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to