mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +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:
@@ -569,7 +569,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
|
||||
return {}
|
||||
|
||||
@classmethod
|
||||
def apply_limit_to_sql(cls, sql: str, limit: int, database: "Database") -> str:
|
||||
def apply_limit_to_sql(
|
||||
cls, sql: str, limit: int, database: "Database", force: bool = False
|
||||
) -> str:
|
||||
"""
|
||||
Alters the SQL statement to apply a LIMIT clause
|
||||
|
||||
@@ -590,7 +592,7 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
|
||||
|
||||
if cls.limit_method == LimitMethod.FORCE_LIMIT:
|
||||
parsed_query = sql_parse.ParsedQuery(sql)
|
||||
sql = parsed_query.set_or_update_query_limit(limit)
|
||||
sql = parsed_query.set_or_update_query_limit(limit, force=force)
|
||||
|
||||
return sql
|
||||
|
||||
|
||||
Reference in New Issue
Block a user