You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/02/19 07:59:32 UTC

[GitHub] [superset] villebro commented on a change in pull request #18746: fix(mssql): support top syntax for limiting queries

villebro commented on a change in pull request #18746:
URL: https://github.com/apache/superset/pull/18746#discussion_r810462157



##########
File path: superset/sql_parse.py
##########
@@ -41,7 +50,6 @@
 CTE_PREFIX = "CTE__"
 logger = logging.getLogger(__name__)
 
-

Review comment:
       nit: maybe add this back to avoid making unrelated changes

##########
File path: superset/sql_lab.py
##########
@@ -292,10 +292,14 @@ def apply_limit_if_exists(
 ) -> str:
     if query.limit and increased_limit:
         # We are fetching one more than the requested limit in order
-        # to test whether there are more rows than the limit.
+        # to test whether there are more rows than the limit. According to the DB
+        # Engine support it will choose top or limit parse
         # Later, the extra row will be dropped before sending
         # the results back to the user.
-        sql = database.apply_limit_to_sql(sql, increased_limit, force=True)
+        if database.db_engine_spec.allow_limit_clause:
+            sql = database.apply_limit_to_sql(sql, increased_limit, force=True)
+        else:
+            sql = database.apply_top_to_sql(sql, increased_limit)

Review comment:
       nit: this check should probably be done in `Database. apply_top_to_sql` so callers don't need to be aware of LIMIT/TOP.




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

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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