betodealmeida commented on a change in pull request #13521:
URL: https://github.com/apache/superset/pull/13521#discussion_r624168537
##########
File path: superset/views/core.py
##########
@@ -2599,8 +2608,16 @@ def csv(self, client_id: str) -> FlaskResponse: #
pylint: disable=no-self-use
logger.info("Using pandas to convert to CSV")
else:
logger.info("Running a query to turn into CSV")
- sql = query.select_sql or query.executed_sql
- df = query.database.get_df(sql, query.schema)
+ if query.select_sql:
+ sql = query.select_sql
+ limit = None
+ else:
+ sql = query.executed_sql
+ limit = ParsedQuery(sql).limit
+ if limit is not None:
+ limit -= 1
Review comment:
I just realized something here. For historical queries (executed before
this PR) `executed_sql` does not have the increased limit, so this would return
one less row. I think we need to check if the query was somehow limited, and
only then we remove the extra row:
```suggestion
if query.limiting_factor in {
LimitingFactor.QUERY,
LimitingFactor.DROPDOWN,
LimitingFactor.QUERY_AND_DROPDOWN,
}:
limit -= 1
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]