Skip to content

Commit

Permalink
[IOTDB-6298] Fix number overflow in group by time interval
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieTien97 authored Feb 22, 2024
1 parent f5b88fb commit 8b5a6d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ public static long calcPositiveIntervalByMonth(long startTime, TimeDuration dura
public static TimeDuration constructTimeDuration(String duration) {
duration = duration.toLowerCase();
String currTimePrecision = CommonDescriptor.getInstance().getConfig().getTimestampPrecision();
int temp = 0;
int monthDuration = 0;
long temp = 0;
long monthDuration = 0;
long nonMonthDuration = 0;
for (int i = 0; i < duration.length(); i++) {
char ch = duration.charAt(i);
Expand Down Expand Up @@ -809,6 +809,6 @@ public static TimeDuration constructTimeDuration(String duration) {
temp = 0;
}
}
return new TimeDuration(monthDuration, nonMonthDuration);
return new TimeDuration((int) monthDuration, nonMonthDuration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,8 @@ public void testConstructTimeDuration() {
timeDuration = DateTimeUtils.constructTimeDuration("1y1mo");
Assert.assertEquals(13, timeDuration.monthDuration);
Assert.assertEquals(0, timeDuration.nonMonthDuration);

timeDuration = DateTimeUtils.constructTimeDuration("10000000000ms");
Assert.assertEquals(10000000000L, timeDuration.nonMonthDuration);
}
}

0 comments on commit 8b5a6d7

Please sign in to comment.