jixuan1989 commented on a change in pull request #2571:
URL: https://github.com/apache/iotdb/pull/2571#discussion_r565875861
##########
File path: server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
##########
@@ -668,6 +666,23 @@ private TSExecuteStatementResp
internalExecuteQueryStatement(String statement, l
}
}
+ /*
+ calculate fetch size for group by time plan
+ */
+ private int getFetchSizeForGroupByTimePlan(GroupByTimePlan groupByTimePlan) {
+ int rows = (int) ((groupByTimePlan.getEndTime() -
groupByTimePlan.getStartTime()) / groupByTimePlan
+ .getInterval());
+ // edge case for group by months when starttime is in February
+ // ie. time range = [2020-02-02, 2020-03-02), interval = 1mo, rows will
get 0
+ if (rows == 0 && groupByTimePlan.isIntervalByMonth()) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(groupByTimePlan.getStartTime());
+ calendar.add(Calendar.MONTH, (int) (groupByTimePlan.getInterval() /
MS_TO_MONTH));
+ rows = calendar.getTimeInMillis() <= groupByTimePlan.getEndTime() ? 1 :
0;
+ }
Review comment:
if rows==0 and !plan.isIntervalByMonth()
set rows = 1;
e.g., select avg(*) from root group by ( [now() -1h, now()), 7200s) will
return 1 row
----------------------------------------------------------------
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]