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


##########
superset/sql/parse.py:
##########
@@ -2178,6 +2300,35 @@ def set_limit_value(
         if not isinstance(self._parsed, exp.Query):
             return
 
+        # Oracle only gained `FETCH FIRST` in 12c, and that is how sqlglot
+        # renders every Oracle limit, so on 10g and 11g a limited query fails
+        # with "ORA-00933: SQL command not properly ended". There, cap the rows
+        # by filtering the original query on `ROWNUM` from outside. `ROWNUM` is
+        # assigned after the inner `ORDER BY` runs, so the first `n` rows are
+        # still the top `n`. SQLAlchemy uses the same rewrite for pre-12c
+        # servers. Later releases keep `FETCH FIRST`, because the wrapper 
rejects
+        # duplicate output column names (ORA-00918) that `FETCH FIRST` accepts.
+        if method == LimitMethod.WRAP_ROWNUM:
+            inner = self._parsed.copy()
+            # Keep CTEs at statement level rather than inside the derived 
table.
+            cte = inner.args.pop("with_", None)
+            _deduplicate_oracle_output_names(inner)

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Leave star projections unchanged in the Oracle limit rewrite when their 
output names cannot be determined without schema; callers can alias columns to 
avoid duplicate names.
   
   **Applied to:**
     - `superset/sql/parse.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



-- 
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