[td-1477]
This commit is contained in:
parent
6ea7e4ee84
commit
010c30afbf
|
@ -711,13 +711,16 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY en
|
|||
if (pCtx->aOutputBuf == NULL) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
}
|
||||
|
||||
SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
||||
if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
} else { // data in current block is not earlier than current result
|
||||
return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
}
|
||||
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
// TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
|
||||
// is invalid
|
||||
// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
||||
// if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
// return BLK_DATA_ALL_NEEDED;
|
||||
// } else { // data in current block is not earlier than current result
|
||||
// return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
// }
|
||||
}
|
||||
|
||||
static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) {
|
||||
|
@ -730,12 +733,16 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end
|
|||
return BLK_DATA_ALL_NEEDED;
|
||||
}
|
||||
|
||||
SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
||||
if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
} else {
|
||||
return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
}
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
// TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
|
||||
// is invalid
|
||||
|
||||
// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
||||
// if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
// return BLK_DATA_ALL_NEEDED;
|
||||
// } else {
|
||||
// return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
// }
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -784,6 +784,8 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed
|
|||
SQuery * pQuery = pRuntimeEnv->pQuery;
|
||||
SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx;
|
||||
|
||||
bool hasPrev = pCtx[0].preAggVals.isSet;
|
||||
|
||||
if (IS_MASTER_SCAN(pRuntimeEnv) || closed) {
|
||||
for (int32_t k = 0; k < pQuery->numOfOutput; ++k) {
|
||||
pCtx[k].nStartQueryTimestamp = pWin->skey;
|
||||
|
@ -796,11 +798,17 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed
|
|||
}
|
||||
|
||||
// not a whole block involved in query processing, statistics data can not be used
|
||||
pCtx[k].preAggVals.isSet = (forwardStep == numOfTotal);
|
||||
// NOTE: the original value of isSet have been changed here
|
||||
if (pCtx[k].preAggVals.isSet && forwardStep < numOfTotal) {
|
||||
pCtx[k].preAggVals.isSet = false;
|
||||
}
|
||||
|
||||
if (functionNeedToExecute(pRuntimeEnv, &pCtx[k], functionId)) {
|
||||
aAggs[functionId].xFunction(&pCtx[k]);
|
||||
}
|
||||
|
||||
// restore it
|
||||
pCtx[k].preAggVals.isSet = hasPrev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,22 +65,23 @@ endi
|
|||
if $data00 != @18-09-18 01:40:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
#if $data01 != NULL then
|
||||
|
||||
if $data01 != 999 then
|
||||
return -1
|
||||
endi
|
||||
#if $data02 != NULL then
|
||||
endi
|
||||
|
||||
if $data02 != 999 then
|
||||
return -1
|
||||
endi
|
||||
#if $data03 != NULL then
|
||||
endi
|
||||
|
||||
if $data03 != 999.00000 then
|
||||
return -1
|
||||
endi
|
||||
#if $data04 != NULL then
|
||||
|
||||
if $data04 != 999.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#if $data05 != NULL then
|
||||
if $data05 != 999 then
|
||||
return -1
|
||||
|
@ -127,7 +128,7 @@ if $data01 != 0 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
#add check for out of range first/last query
|
||||
print =============> add check for out of range first/last query
|
||||
sql select first(ts),last(ts) from first_tb4 where ts>'2018-9-18 1:40:01';
|
||||
if $row != 0 then
|
||||
return -1
|
||||
|
@ -136,4 +137,129 @@ endi
|
|||
sql select first(ts),last(ts) from first_tb4 where ts<'2018-9-17 8:50:0';
|
||||
if $row != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#first/last mix up query
|
||||
#select first(size),last(size) from stest interval(1d) group by tbname;
|
||||
print =====================>td-1477
|
||||
|
||||
sql create table stest(ts timestamp,size INT,filenum INT) tags (appname binary(500),tenant binary(500));
|
||||
sql insert into test1 using stest tags('test1','aaa') values ('2020-09-04 16:53:54.003',210,3);
|
||||
sql insert into test2 using stest tags('test1','aaa') values ('2020-09-04 16:53:56.003',210,3);
|
||||
sql insert into test11 using stest tags('test11','bbb') values ('2020-09-04 16:53:57.003',210,3);
|
||||
sql insert into test12 using stest tags('test11','bbb') values ('2020-09-04 16:53:58.003',210,3);
|
||||
sql insert into test21 using stest tags('test21','ccc') values ('2020-09-04 16:53:59.003',210,3);
|
||||
sql insert into test22 using stest tags('test21','ccc') values ('2020-09-04 16:54:54.003',210,3);
|
||||
sql select sum(size) from stest group by appname;
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 420 then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != 420 then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != 420 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != @test1@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != @test11@ then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != @test21@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select sum(size) from stest interval(1d) group by appname;
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#2020-09-04 00:00:00.000 | 420 | test1 |
|
||||
#2020-09-04 00:00:00.000 | 420 | test11 |
|
||||
#2020-09-04 00:00:00.000 | 420 | test21 |
|
||||
if $data00 != @20-09-04 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @20-09-04 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data20 != @20-09-04 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 420 then
|
||||
print expect 420 , actual $data01
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 420 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data21 != 420 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != @test1@ then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != @test11@ then
|
||||
return -1
|
||||
endi
|
||||
if $data22 != @test21@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print ===================>td-1477, one table has only one block occurs this bug.
|
||||
sql select first(size),count(*),LAST(SIZE) from stest where tbname in ('test1', 'test2') interval(1d) group by tbname;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @20-09-04 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 210 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 210 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data04 != @test1@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @20-09-04 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 210 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data13 != 210 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data14 != @test11@ then
|
||||
return -1
|
||||
endi
|
Loading…
Reference in New Issue