mirror of
https://github.com/apache/superset.git
synced 2026-04-27 03:55:47 +00:00
feat: Logic added to limiting factor column in Query model (#13521)
* Sqllab limit * Add migration script * Set default values * initial push * revisions * Update superset/views/core.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * moving migration to separate PR * with migration * revisions * Fix apply_limit_to_sql * all but tests * added unit tests * revisions * Update superset/sql_lab.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/sql_parse.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * fixed black issue * Update superset/views/core.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * updated logic Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
This commit is contained in:
@@ -311,7 +311,7 @@ class ParsedQuery:
|
||||
if any(not self._is_identifier(token2) for token2 in item.tokens):
|
||||
self._extract_from_token(item)
|
||||
|
||||
def set_or_update_query_limit(self, new_limit: int) -> str:
|
||||
def set_or_update_query_limit(self, new_limit: int, force: bool = False) -> str:
|
||||
"""Returns the query with the specified limit.
|
||||
|
||||
Does not change the underlying query if user did not apply the limit,
|
||||
@@ -332,8 +332,8 @@ class ParsedQuery:
|
||||
break
|
||||
_, limit = statement.token_next(idx=limit_pos)
|
||||
# Override the limit only when it exceeds the configured value.
|
||||
if limit.ttype == sqlparse.tokens.Literal.Number.Integer and new_limit < int(
|
||||
limit.value
|
||||
if limit.ttype == sqlparse.tokens.Literal.Number.Integer and (
|
||||
force or new_limit < int(limit.value)
|
||||
):
|
||||
limit.value = new_limit
|
||||
elif limit.is_group:
|
||||
|
||||
Reference in New Issue
Block a user