betodealmeida commented on a change in pull request #13521:
URL: https://github.com/apache/superset/pull/13521#discussion_r589846295



##########
File path: superset/views/core.py
##########
@@ -2566,6 +2579,12 @@ def sql_json_exec(  # pylint: 
disable=too-many-statements,too-many-locals
         if not (config.get("SQLLAB_CTAS_NO_LIMIT") and select_as_cta):
             # set LIMIT after template processing
             limits = [mydb.db_engine_spec.get_limit_from_sql(rendered_query), 
limit]
+            if limits[0] == limits[1]:
+                query.limiting_factor = LimitingFactor.QUERY_AND_DROPDOWN
+            elif limits[0] > limits[1]:
+                query.limiting_factor = LimitingFactor.DROPDOWN
+            else:
+                query.limiting_factor = LimitingFactor.QUERY

Review comment:
       Looking at line 2588 it seems that one of the values in `limits` could 
be `None`, so we might need to improve this to something like:
   
   ```suggestion
               if limits[0] is None and limits[1] is None:
                   query.limiting_factor = LimitingFactor.NOT_LIMITED
               elif limits[0] is None or limits[0] > limits[1]:
                   query.limiting_factor = LimitingFactor.DROPDOWN
               elif limits[1] is None or limits[1] > limits[0]:
                   query.limiting_factor = LimitingFactor.QUERY
               else:  # limits[0] == limits[1]
                   query.limiting_factor = LimitingFactor.QUERY_AND_DROPDOWN
   ```
   
   Looking at the source code only `limits[0]` can be `None`, but I'd leave the 
check as above just to be safe. If `mypy` complains we can get rid of the first 
test in the block above, since in theory it should never happen (`limit` is an 
int, and so should be `limits[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]

Reply via email to