fix(query): set the correct number of rows when calculating using sma for min/max function.
This commit is contained in:
parent
84f8c7675f
commit
f803fa44b5
|
@ -2839,12 +2839,11 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
||||||
|
|
||||||
ASSERT(pBlockInfo != NULL);
|
ASSERT(pBlockInfo != NULL);
|
||||||
|
|
||||||
if (pBlockInfo != NULL) {
|
// if (pBlockInfo != NULL) {
|
||||||
pScanInfo =
|
pScanInfo = *(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
||||||
*(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
// } else {
|
||||||
} else {
|
// pScanInfo = *pReader->status.pTableIter;
|
||||||
pScanInfo = *pReader->status.pTableIter;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
if (pScanInfo == NULL) {
|
if (pScanInfo == NULL) {
|
||||||
tsdbError("failed to get table scan-info, %s", pReader->idStr);
|
tsdbError("failed to get table scan-info, %s", pReader->idStr);
|
||||||
|
@ -2852,46 +2851,14 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBlockInfo != NULL) {
|
// if (pBlockInfo != NULL) {
|
||||||
pBlock = getCurrentBlock(pBlockIter);
|
pBlock = getCurrentBlock(pBlockIter);
|
||||||
}
|
// }
|
||||||
|
|
||||||
initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
|
initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
|
||||||
TSDBKEY keyInBuf = getCurrentKeyInBuf(pScanInfo, pReader);
|
TSDBKEY keyInBuf = getCurrentKeyInBuf(pScanInfo, pReader);
|
||||||
|
|
||||||
/*if (pBlockInfo == NULL) { // build data block from last data file
|
if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) {
|
||||||
SBlockData* pBData = &pReader->status.fileBlockData;
|
|
||||||
tBlockDataReset(pBData);
|
|
||||||
|
|
||||||
SSDataBlock* pResBlock = pReader->pResBlock;
|
|
||||||
tsdbDebug("load data in last block firstly, due to desc scan data, %s", pReader->idStr);
|
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
bool hasBlockLData = hasDataInLastBlock(pLastBlockReader);
|
|
||||||
|
|
||||||
// no data in last block and block, no need to proceed.
|
|
||||||
if (hasBlockLData == false) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader);
|
|
||||||
if (pResBlock->info.rows >= pReader->capacity) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
|
||||||
updateComposedBlockInfo(pReader, el, pScanInfo);
|
|
||||||
|
|
||||||
if (pResBlock->info.rows > 0) {
|
|
||||||
tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64
|
|
||||||
" rows:%d, elapsed time:%.2f ms %s",
|
|
||||||
pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey,
|
|
||||||
pResBlock->info.rows, el, pReader->idStr);
|
|
||||||
}
|
|
||||||
} else*/ if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) {
|
|
||||||
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pScanInfo->uid);
|
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pScanInfo->uid);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -714,26 +714,18 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
||||||
pBuf->type = type;
|
pBuf->type = type;
|
||||||
|
|
||||||
if (IS_NULL_TYPE(type)) {
|
if (IS_NULL_TYPE(type)) {
|
||||||
numOfElems = 0;
|
|
||||||
goto _over;
|
goto _over;
|
||||||
}
|
}
|
||||||
|
|
||||||
// data in current data block are qualified to the query
|
// data in current data block are qualified to the query
|
||||||
if (pInput->colDataSMAIsSet) {
|
if (pInput->colDataSMAIsSet) {
|
||||||
numOfElems = pInput->numOfRows - pAgg->numOfNull;
|
numOfElems = pInput->numOfRows - pAgg->numOfNull;
|
||||||
|
|
||||||
if (numOfElems == 0) {
|
if (numOfElems == 0) {
|
||||||
goto _over;
|
goto _over;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* tval = NULL;
|
|
||||||
int16_t index = 0;
|
int16_t index = 0;
|
||||||
|
void* tval = (isMinFunc) ? &pInput->pColumnDataAgg[0]->min : &pInput->pColumnDataAgg[0]->max;
|
||||||
if (isMinFunc) {
|
|
||||||
tval = &pInput->pColumnDataAgg[0]->min;
|
|
||||||
} else {
|
|
||||||
tval = &pInput->pColumnDataAgg[0]->max;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pBuf->assign) {
|
if (!pBuf->assign) {
|
||||||
if (type == TSDB_DATA_TYPE_FLOAT) {
|
if (type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
|
@ -824,8 +816,9 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
numOfElems = 1;
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
goto _over;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t start = pInput->startRowIndex;
|
int32_t start = pInput->startRowIndex;
|
||||||
|
|
|
@ -31,13 +31,8 @@ sql insert into $tb values ( $ts , $x )
|
||||||
$x = $x + 1
|
$x = $x + 1
|
||||||
endw
|
endw
|
||||||
|
|
||||||
print ================== restart server to commit data into disk
|
sql flush database $db
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
|
||||||
print ================== server restart completed
|
|
||||||
sql connect
|
|
||||||
|
|
||||||
sql use $db
|
|
||||||
sql delete from $tb where ts=1537146000000
|
sql delete from $tb where ts=1537146000000
|
||||||
sql delete from $tb where ts=1537146409500
|
sql delete from $tb where ts=1537146409500
|
||||||
|
|
||||||
|
@ -63,7 +58,6 @@ if $rows != 8198 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print ===========================> TD-22077 && TD-21877
|
|
||||||
sql drop database if exists $db -x step1
|
sql drop database if exists $db -x step1
|
||||||
sql create database $db vgroups 1;
|
sql create database $db vgroups 1;
|
||||||
|
|
||||||
|
@ -88,6 +82,8 @@ endw
|
||||||
|
|
||||||
sql flush database $db
|
sql flush database $db
|
||||||
|
|
||||||
|
print ===========================> TD-22077 && TD-21877
|
||||||
|
|
||||||
sql insert into t1 values('2018-09-17 09:00:26', 26);
|
sql insert into t1 values('2018-09-17 09:00:26', 26);
|
||||||
sql insert into t2 values('2018-09-17 09:00:25', 25);
|
sql insert into t2 values('2018-09-17 09:00:25', 25);
|
||||||
|
|
||||||
|
@ -97,4 +93,33 @@ sql flush database reg_db0;
|
||||||
sql delete from st1 where ts<='2018-9-17 09:00:26';
|
sql delete from st1 where ts<='2018-9-17 09:00:26';
|
||||||
sql select * from st1;
|
sql select * from st1;
|
||||||
|
|
||||||
|
sql drop table t1
|
||||||
|
sql drop table t2
|
||||||
|
|
||||||
|
print =========================================>TD-22196
|
||||||
|
sql create table t1 using st1 tags(1);
|
||||||
|
|
||||||
|
$i = 0
|
||||||
|
$ts = 1674977959000
|
||||||
|
$rowNum = 200
|
||||||
|
|
||||||
|
$x = 0
|
||||||
|
while $x < $rowNum
|
||||||
|
$xs = $x * $delta
|
||||||
|
$ts = $ts0 + $xs
|
||||||
|
sql insert into t1 values ( $ts , $x )
|
||||||
|
$x = $x + 1
|
||||||
|
$ts = $ts + 1000
|
||||||
|
endw
|
||||||
|
|
||||||
|
sql flush database $db
|
||||||
|
sql select min(c),max(c) from t1
|
||||||
|
if $data00 != 0 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 199 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
Loading…
Reference in New Issue