MCPcopy
hub / github.com/marimo-team/marimo / _query_includes_limit

Function _query_includes_limit

marimo/_sql/sql.py:216–236  ·  view source on GitHub ↗

Check if a SQL query includes a LIMIT clause.

(query: str)

Source from the content-addressed store, hash-verified

214
215
216def _query_includes_limit(query: str) -> bool:
217 """Check if a SQL query includes a LIMIT clause."""
218 import sqlglot
219 from sqlglot.expressions import Limit, Select
220
221 try:
222 expressions = sqlglot.parse(query.strip())
223 except Exception:
224 # May not be valid SQL
225 return False
226
227 if not expressions:
228 return False
229
230 # Only check the last statement in case of multiple statements
231 last_expr = expressions[-1]
232 if not isinstance(last_expr, Select):
233 return False
234
235 # Look for any LIMIT clause in the SELECT statement
236 return last_expr.find(Limit) is not None

Callers 2

sqlFunction · 0.85

Calls 3

stripMethod · 0.80
parseMethod · 0.65
findMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…