mirror of https://github.com/apache/superset.git
Allow LIMIT to be specified in parameters (#7052)
This commit is contained in:
parent
7d95036554
commit
f66b598d37
|
@ -2558,10 +2558,8 @@ class Superset(BaseSupersetView):
|
||||||
)
|
)
|
||||||
|
|
||||||
client_id = request.form.get('client_id') or utils.shortid()[:10]
|
client_id = request.form.get('client_id') or utils.shortid()[:10]
|
||||||
limits = [mydb.db_engine_spec.get_limit_from_sql(sql), limit]
|
|
||||||
query = Query(
|
query = Query(
|
||||||
database_id=int(database_id),
|
database_id=int(database_id),
|
||||||
limit=min(lim for lim in limits if lim is not None),
|
|
||||||
sql=sql,
|
sql=sql,
|
||||||
schema=schema,
|
schema=schema,
|
||||||
select_as_cta=request.form.get('select_as_cta') == 'true',
|
select_as_cta=request.form.get('select_as_cta') == 'true',
|
||||||
|
@ -2591,6 +2589,10 @@ class Superset(BaseSupersetView):
|
||||||
return json_error_response(
|
return json_error_response(
|
||||||
'Template rendering failed: {}'.format(utils.error_msg_from_exception(e)))
|
'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.
|
# Async request.
|
||||||
if async_:
|
if async_:
|
||||||
logging.info('Running query on a Celery worker')
|
logging.info('Running query on a Celery worker')
|
||||||
|
|
Loading…
Reference in New Issue