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


##########
tests/unit_tests/sql/parse_tests.py:
##########
@@ -938,6 +938,54 @@ def test_sqlscript() -> None:
     assert query.get_settings() == {"querytrace": True}
 
 
+def test_sqlscript_format_preserves_optimizer_hint_block() -> None:
+    """
+    Regression for #38189: an inline `--` comment trailing a query with a
+    `/*+ SET_VAR(...) */` optimizer hint must not get repositioned inside
+    the hint block during `format()` -- that would corrupt the hint syntax
+    (StarRocks and other engines using the `/*+ ... */` convention reject
+    a nested `/* */` inside it). `format()` is what Superset's execution
+    path actually sends to the engine (see `executor.py`/`celery_task.py`).
+    """
+    sql = """SELECT /*+ SET_VAR(query_timeout = 3000) */ col1, col2
+FROM my_table
+LIMIT 100
+
+-- increase timeout for large scans"""
+    statement = SQLScript(sql, "starrocks").statements[0]
+    formatted = statement.format()
+
+    assert "/*+ SET_VAR(query_timeout = 3000) */" in formatted
+    assert "SET_VAR(query_timeout /*" not in formatted

Review Comment:
   **Suggestion:** The oracle is too narrow: it only rejects the exact 
corruption string `SET_VAR(query_timeout /*`. A formatter can still inject a 
nested comment elsewhere inside the optimizer hint, or drop/reposition the 
trailing comment incorrectly, while satisfying both assertions. Assert that the 
complete hint remains unchanged and that the trailing comment is preserved 
outside the hint block, applying the same stronger oracle to the semicolon 
case. [possible bug]
   
   <details>
   <summary><b>Severity Level:</b> Minor ๐Ÿงน</summary>
   
   ```mdx
   - โš ๏ธ Regression test can miss lost trailing comments.
   - โš ๏ธ Semicolon corruption oracle remains unnecessarily narrow.
   - โš ๏ธ Execution SQL formatting is insufficiently validated.
   ```
   </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=54e11243f20d479bad051dc1b638abbd&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=54e11243f20d479bad051dc1b638abbd&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/unit_tests/sql/parse_tests.py
   **Line:** 958:959
   **Comment:**
        *Possible Bug: The oracle is too narrow: it only rejects the exact 
corruption string `SET_VAR(query_timeout /*`. A formatter can still inject a 
nested comment elsewhere inside the optimizer hint, or drop/reposition the 
trailing comment incorrectly, while satisfying both assertions. Assert that the 
complete hint remains unchanged and that the trailing comment is preserved 
outside the hint block, applying the same stronger oracle to the semicolon case.
   
   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%2F42733&comment_hash=a01c00766712d9be966a46f22e7e3c0813d9dc458bc9c53291e580fb8bbb6ce0&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42733&comment_hash=a01c00766712d9be966a46f22e7e3c0813d9dc458bc9c53291e580fb8bbb6ce0&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