Merge pull request #24529 from taosdata/szhou/fix/td-28350
fix: calculate interval end with new alogrithm
This commit is contained in:
commit
66c30f861f
|
@ -1858,7 +1858,7 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI
|
||||||
STimeWindow w = {0};
|
STimeWindow w = {0};
|
||||||
if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value
|
if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value
|
||||||
getInitialStartTimeWindow(pInterval, ts, &w, (order == TSDB_ORDER_ASC));
|
getInitialStartTimeWindow(pInterval, ts, &w, (order == TSDB_ORDER_ASC));
|
||||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
w.ekey = taosTimeGetIntervalEnd(w.skey, pInterval);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "tsimplehash.h"
|
#include "tsimplehash.h"
|
||||||
#include "executor.h"
|
#include "executor.h"
|
||||||
|
#include "executorInt.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
@ -186,4 +187,20 @@ TEST(testCase, timewindow_natural) {
|
||||||
ASSERT_EQ(w3.skey, w4.skey);
|
ASSERT_EQ(w3.skey, w4.skey);
|
||||||
ASSERT_EQ(w3.ekey, w4.ekey);
|
ASSERT_EQ(w3.ekey, w4.ekey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST(testCase, timewindow_active) {
|
||||||
|
osSetTimezone("CST");
|
||||||
|
int32_t precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
|
int64_t offset = (int64_t)2*365*24*60*60*1000;
|
||||||
|
SInterval interval = createInterval(10, 10, offset, 'y', 'y', 0, precision);
|
||||||
|
SResultRowInfo dumyInfo = {0};
|
||||||
|
dumyInfo.cur.pageId = -1;
|
||||||
|
int64_t key = (int64_t)1609430400*1000; // 2021-01-01
|
||||||
|
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, key, &interval, TSDB_ORDER_ASC);
|
||||||
|
printTimeWindow(&win, precision, key);
|
||||||
|
printf("%ld win %ld, %ld\n", key, win.skey, win.ekey);
|
||||||
|
ASSERT_EQ(win.skey, 1325376000000);
|
||||||
|
ASSERT_EQ(win.ekey, 1640908799999);
|
||||||
|
}
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
Loading…
Reference in New Issue