You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2019/03/25 14:31:09 UTC

[GitHub] [drill] vvysotskyi commented on a change in pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option

vvysotskyi commented on a change in pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option
URL: https://github.com/apache/drill/pull/1714#discussion_r268648485
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java
 ##########
 @@ -107,6 +108,20 @@ public QueryContext(final UserSession session, final DrillbitContext drillbitCon
       this.table = drillbitContext.getOperatorTable();
     }
 
+    // Checking for limit on ResultSet rowcount and if user attempting to override the system value
+    int sessionMaxRowCount = queryOptions.getOption(ExecConstants.QUERY_MAX_ROWS).num_val.intValue();
+    int defaultMaxRowCount = queryOptions.getOptionManager(OptionScope.SYSTEM).getOption(ExecConstants.QUERY_MAX_ROWS).num_val.intValue();
+    if (sessionMaxRowCount > 0 && defaultMaxRowCount > 0) {
+      this.autoLimitRowCount = Math.min(sessionMaxRowCount, defaultMaxRowCount);
+    } else {
+      this.autoLimitRowCount = Math.max(sessionMaxRowCount, defaultMaxRowCount);
+    }
+    if (autoLimitRowCount == defaultMaxRowCount && defaultMaxRowCount != sessionMaxRowCount) {
+      // Required to indicate via OptionScope=QueryLevel that session limit is overridden by system limit
+      queryOptions.setLocalOption(ExecConstants.QUERY_MAX_ROWS, autoLimitRowCount);
+    }
+    logger.debug("ResultSet size is auto-limited to {} rows [Session: {} / Default: {}]", this.autoLimitRowCount, sessionMaxRowCount, defaultMaxRowCount);
 
 Review comment:
   This message will be logged even for the case when auto limit does not happen.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services