mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
feat: implement limit extraction in sqlglot (#33456)
This commit is contained in:
@@ -27,7 +27,7 @@ from superset.commands.base import BaseCommand
|
||||
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
|
||||
from superset.exceptions import SupersetErrorException, SupersetSecurityException
|
||||
from superset.models.sql_lab import Query
|
||||
from superset.sql_parse import ParsedQuery
|
||||
from superset.sql.parse import SQLScript
|
||||
from superset.sqllab.limiting_factor import LimitingFactor
|
||||
from superset.utils import core as utils, csv
|
||||
from superset.views.utils import _deserialize_results_payload
|
||||
@@ -115,10 +115,9 @@ class SqlResultExportCommand(BaseCommand):
|
||||
limit = None
|
||||
else:
|
||||
sql = self._query.executed_sql
|
||||
limit = ParsedQuery(
|
||||
sql,
|
||||
engine=self._query.database.db_engine_spec.engine,
|
||||
).limit
|
||||
script = SQLScript(sql, self._query.database.db_engine_spec.engine)
|
||||
# when a query has multiple statements only the last one returns data
|
||||
limit = script.statements[-1].get_limit_value()
|
||||
if limit is not None and self._query.limiting_factor in {
|
||||
LimitingFactor.QUERY,
|
||||
LimitingFactor.DROPDOWN,
|
||||
|
||||
Reference in New Issue
Block a user