fix(query): fix floating type handle sma error
This commit is contained in:
parent
3c331dc145
commit
d8b8ece9c1
|
@ -784,7 +784,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
pEntryInfo->isNullRes = (pEntryInfo->numOfRes == 0) ? 1 : 0;
|
||||
|
||||
if (pCol->info.type == TSDB_DATA_TYPE_FLOAT) {
|
||||
float v = *(float*)&pRes->v;
|
||||
float v = GET_DOUBLE_VAL(&pRes->v);
|
||||
colDataAppend(pCol, currentRow, (const char*)&v, pEntryInfo->isNullRes);
|
||||
} else {
|
||||
colDataAppend(pCol, currentRow, (const char*)&pRes->v, pEntryInfo->isNullRes);
|
||||
|
|
|
@ -737,6 +737,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
|||
|
||||
if (!pBuf->assign) {
|
||||
pBuf->v = *(int64_t*)tval;
|
||||
|
||||
if (pCtx->subsidiaries.num > 0) {
|
||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||
if (index >= 0) {
|
||||
|
@ -788,11 +789,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
|||
}
|
||||
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
||||
float prev = 0;
|
||||
GET_TYPED_DATA(prev, float, type, &pBuf->v);
|
||||
GET_TYPED_DATA(prev, float, TSDB_DATA_TYPE_DOUBLE, &pBuf->v);
|
||||
|
||||
float val = GET_DOUBLE_VAL(tval);
|
||||
if ((prev < val) ^ isMinFunc) {
|
||||
*(float*)&pBuf->v = val;
|
||||
*(double*)&pBuf->v = GET_DOUBLE_VAL(tval);
|
||||
}
|
||||
|
||||
if (pCtx->subsidiaries.num > 0) {
|
||||
|
@ -888,4 +889,4 @@ _over:
|
|||
}
|
||||
|
||||
return numOfElems;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue