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


##########
superset/sql/parse.py:
##########
@@ -1139,6 +1139,22 @@ def _deduplicate_oracle_output_names(query: 
exp.Expression) -> None:
             projection.replace(exp.alias_(projection.copy(), alias))
 
 
+def _flatten_and(condition: exp.Expression) -> list[exp.Expression]:
+    """
+    Return the leaves of a chain of `AND`s, looking through parentheses.
+
+    `exp.And.flatten()` only unwraps a left- or right-leaning chain of plain
+    `AND`s; a nested `AND` grouped in parentheses, as in `x AND (y AND z)`,
+    comes back as a single `And` leaf rather than its own `y` and `z` leaves.
+    This recurses instead, so a condition `AND`-ed together with others stays
+    found regardless of how it is grouped.
+    """
+    condition = condition.unnest()
+    if not isinstance(condition, exp.And):
+        return [condition]
+    return _flatten_and(condition.this) + _flatten_and(condition.expression)

Review Comment:
   **Suggestion:** A long left-associated AND chain increases recursion depth 
per predicate; near Python’s recursion limit, limit inspection raises 
RecursionError and aborts query handling.
   
   **Assessment:** 🟠 `Major` · 🔁 `Occurrence: Rarely` · 🏷️ `Possible bug`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![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=73cf8f8393144d31b949ed76b1ec55f4&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=73cf8f8393144d31b949ed76b1ec55f4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/sql/parse.py
   **Line:** 1155:1155
   **Comment:**
        *Possible Bug: A long left-associated AND chain increases recursion 
depth per predicate; near Python’s recursion limit, limit inspection raises 
RecursionError and aborts query handling.
   
   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%2F45771&comment_hash=150d6b6a9c5a21cc94cd5e75a510fcf27ccd6461a8da0298b2609c71d2770405&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45771&comment_hash=150d6b6a9c5a21cc94cd5e75a510fcf27ccd6461a8da0298b2609c71d2770405&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