ihuzenko commented on a change in pull request #1608: DRILL-6960: AutoLimit the 
size of ResultSet for a WebUI (or REST) client
URL: https://github.com/apache/drill/pull/1608#discussion_r257194898
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
 ##########
 @@ -183,4 +188,36 @@ private static PhysicalPlan getQueryPlan(QueryContext 
context, String sql, Point
 
     return handler.getPlan(sqlNode);
   }
+
+  //Check if AutoLimit should be applied
+  private static boolean isAutoLimitShouldBeApplied(QueryContext context, 
SqlNode sqlNode) {
+    return context.isAutoLimitEnabled() && 
sqlNode.getKind().belongsTo(SqlKind.QUERY)
+        && (sqlNode.getKind() != SqlKind.ORDER_BY || 
isAutoLimitLessThanOrderByFetch((SqlOrderBy) sqlNode, context));
+  }
+
+  //Check and apply auto Limit
+  private static SqlNode checkAndApplyAutoLimit(SqlConverter parser, 
QueryContext context, String sql) {
+    SqlNode sqlNode = parser.parse(sql);
+    if (isAutoLimitShouldBeApplied(context, sqlNode)) {
+      sqlNode = wrapWithAutoLimit(sqlNode, context);
+    } else {
+      context.disableAutoLimit();
+    }
+    return sqlNode;
+  }
+
+  //Check if autoLimit is less than existing limit in the query
 
 Review comment:
   method name is self-descriptive,comment is redundant here

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to