kkhatua 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_r268771066
##########
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:
Good point. Will mark it for when autoLimit is non-zero.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services