This is an automated email from the ASF dual-hosted git repository.
christine pushed a commit to branch lyftga
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/lyftga by this push:
new 0e1a3d3 Allow LIMIT to be specified in parameters (#7052)
0e1a3d3 is described below
commit 0e1a3d3fdd2e7ffb1e2c33005eccaaf16a28fb89
Author: Beto Dealmeida <[email protected]>
AuthorDate: Wed Mar 20 16:56:30 2019 -0700
Allow LIMIT to be specified in parameters (#7052)
---
superset/views/core.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/superset/views/core.py b/superset/views/core.py
index 78044c6..a250e60 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2531,10 +2531,8 @@ class Superset(BaseSupersetView):
)
client_id = request.form.get('client_id') or utils.shortid()[:10]
- limits = [mydb.db_engine_spec.get_limit_from_sql(sql), limit]
query = Query(
database_id=int(database_id),
- limit=min(lim for lim in limits if lim is not None),
sql=sql,
schema=schema,
select_as_cta=request.form.get('select_as_cta') == 'true',
@@ -2564,6 +2562,10 @@ class Superset(BaseSupersetView):
return json_error_response(
'Template rendering failed:
{}'.format(utils.error_msg_from_exception(e)))
+ # set LIMIT after template processing
+ limits = [mydb.db_engine_spec.get_limit_from_sql(rendered_query),
limit]
+ query.limit = min(lim for lim in limits if lim is not None)
+
# Async request.
if async_:
logging.info('Running query on a Celery worker')