timifasubaa 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_r189134922
 
 

 ##########
 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:
   Ah, true. I hadn't thought of the subquery case. But split can handle the 
tabs and newlines just fine. I'll go ahead to reuse your regex approach as that 
is more robust. 
   And your suggestion of adding the logic within the checking function makes 
sense. 

----------------------------------------------------------------
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