mistercrunch commented on a change in pull request #5023: [sqllab] force limit 
queries only when there is no existing limit
URL: 
https://github.com/apache/incubator-superset/pull/5023#discussion_r189075550
 
 

 ##########
 File path: superset/utils.py
 ##########
 @@ -841,3 +841,17 @@ def ensure_path_exists(path):
     except OSError as exc:
         if not (os.path.isdir(path) and exc.errno == errno.EEXIST):
             raise
+
+
+def get_limit_from_sql(sql):
+    sql = sql.lower()
+    limit = None
+    tokens = sql.split()
+    try:
+        if 'limit' in tokens:
+            limit_pos = tokens.index('limit') + 1
 
 Review comment:
   Oh that looks brittle here, for example `limit` can exist within a subquery, 
or there can be line breaks or tabs as separators instead of spaces. We should 
use the same method / regex approach as the one I defined. Maybe that method in 
db_engine_spec can receive `max_limit` and only apply alter if the max
   _limit is lower

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to