[TD-6046]<fix> fix ts derivative error

This commit is contained in:
wangmm0220 2021-08-17 11:32:06 +08:00
parent dff67958b1
commit 2a45714d95
2 changed files with 16 additions and 4 deletions

View File

@ -5590,6 +5590,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) {
pRes->info.rows = getNumOfResult(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput); pRes->info.rows = getNumOfResult(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput);
if (pRes->info.rows >= pRuntimeEnv->resultInfo.threshold) { if (pRes->info.rows >= pRuntimeEnv->resultInfo.threshold) {
copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput);
clearNumOfRes(pInfo->pCtx, pOperator->numOfOutput); clearNumOfRes(pInfo->pCtx, pOperator->numOfOutput);
return pRes; return pRes;
} }
@ -5615,8 +5616,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) {
if (*newgroup) { if (*newgroup) {
if (pRes->info.rows > 0) { if (pRes->info.rows > 0) {
pProjectInfo->existDataBlock = pBlock; pProjectInfo->existDataBlock = pBlock;
clearNumOfRes(pInfo->pCtx, pOperator->numOfOutput); break;
return pInfo->pRes;
} else { // init output buffer for a new group data } else { // init output buffer for a new group data
for (int32_t j = 0; j < pOperator->numOfOutput; ++j) { for (int32_t j = 0; j < pOperator->numOfOutput; ++j) {
aAggs[pInfo->pCtx[j].functionId].xFinalize(&pInfo->pCtx[j]); aAggs[pInfo->pCtx[j].functionId].xFinalize(&pInfo->pCtx[j]);
@ -5645,9 +5645,8 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) {
if (pRes->info.rows >= 1000/*pRuntimeEnv->resultInfo.threshold*/) { if (pRes->info.rows >= 1000/*pRuntimeEnv->resultInfo.threshold*/) {
break; break;
} }
copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput);
} }
copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput);
clearNumOfRes(pInfo->pCtx, pOperator->numOfOutput); clearNumOfRes(pInfo->pCtx, pOperator->numOfOutput);
return (pInfo->pRes->info.rows > 0)? pInfo->pRes:NULL; return (pInfo->pRes->info.rows > 0)? pInfo->pRes:NULL;
} }

View File

@ -54,6 +54,19 @@ class TDTestCase:
tdSql.query("select derivative(col, 10s, 0) from stb group by tbname") tdSql.query("select derivative(col, 10s, 0) from stb group by tbname")
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.query("select ts,derivative(col, 10s, 1),ts from stb group by tbname")
tdSql.checkRows(4)
tdSql.checkData(0, 0, self.ts + 10000)
tdSql.checkData(0, 1, self.ts + 10000)
tdSql.checkData(0, 3, self.ts + 10000)
tdSql.checkData(3, 0, self.ts + 70000)
tdSql.checkData(3, 1, self.ts + 70000)
tdSql.checkData(3, 3, self.ts + 70000)
tdSql.query("select ts from(select ts,derivative(col, 10s, 0) from stb group by tbname")
tdSql.checkData(0, 1, 1)
tdSql.error("select derivative(col, 10s, 0) from tb1 group by tbname") tdSql.error("select derivative(col, 10s, 0) from tb1 group by tbname")
tdSql.query("select derivative(col, 10s, 1) from tb1") tdSql.query("select derivative(col, 10s, 1) from tb1")