codeant-ai-for-open-source[bot] commented on code in PR #44604:
URL: https://github.com/apache/superset/pull/44604#discussion_r4109802036
##########
superset/sql/parse.py:
##########
@@ -1770,22 +1780,65 @@ def _has_limit_by(self) -> bool:
def get_limit_value(self) -> int | None:
"""
- Parse a SQL query and return the `LIMIT` or `TOP` value, if present.
+ Return a fixed outer `LIMIT`, `TOP`, or `FETCH` row count, if known.
"""
# `LIMIT 2 BY id` bounds each group, not the result set, so reporting 2
# here would make `_set_query_limit()` clamp the whole query to 2 rows.
if self._has_limit_by():
return None
if limit_node := self._parsed.args.get("limit"):
- literal = limit_node.args.get("expression") or getattr(
- limit_node, "this", None
- )
+ options = limit_node.args.get("limit_options")
+ if options and (
+ options.args.get("percent") or options.args.get("with_ties")
+ ):
+ return None
+ if isinstance(limit_node, exp.Fetch):
+ literal = limit_node.args.get("count")
+ # FETCH FIRST ROW ONLY has an implicit count of one.
+ if literal is None:
+ return 1
+ else:
+ literal = limit_node.args.get("expression")
+ while isinstance(literal, exp.Paren):
+ literal = literal.this
if isinstance(literal, exp.Literal) and literal.is_int:
return int(literal.name)
return None
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `cad654d`.
`cap_limit_value` now detects non-fixed limits returned as `None` and wraps
the query instead of replacing the existing expression, preserving potentially
smaller limits.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
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]