fix hll tsCountAlwaysReturnValue not working

This commit is contained in:
Ganlin Zhao 2022-11-03 15:01:52 +08:00
parent 49715a2898
commit 0b3a3aff21
1 changed files with 16 additions and 2 deletions

View File

@ -181,6 +181,7 @@ typedef enum { UNKNOWN_BIN = 0, USER_INPUT_BIN, LINEAR_BIN, LOG_BIN } EHistoBinT
typedef struct SHLLFuncInfo {
uint64_t result;
uint64_t totalCount;
uint8_t buckets[HLL_BUCKETS];
} SHLLInfo;
@ -4605,7 +4606,14 @@ int32_t hllFunction(SqlFunctionCtx* pCtx) {
}
}
SET_VAL(GET_RES_INFO(pCtx), numOfElems, 1);
pInfo->totalCount += numOfElems;
if (pInfo->totalCount == 0 && !tsCountAlwaysReturnValue) {
SET_VAL(GET_RES_INFO(pCtx), 0, 1);
} else {
SET_VAL(GET_RES_INFO(pCtx), 1, 1);
}
return TSDB_CODE_SUCCESS;
}
@ -4615,6 +4623,7 @@ static void hllTransferInfo(SHLLInfo* pInput, SHLLInfo* pOutput) {
pOutput->buckets[k] = pInput->buckets[k];
}
}
pOutput->totalCount += pInput->totalCount;
}
int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) {
@ -4632,7 +4641,12 @@ int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) {
hllTransferInfo(pInputInfo, pInfo);
}
SET_VAL(GET_RES_INFO(pCtx), 1, 1);
if (pInfo->totalCount == 0 && !tsCountAlwaysReturnValue) {
SET_VAL(GET_RES_INFO(pCtx), 0, 1);
} else {
SET_VAL(GET_RES_INFO(pCtx), 1, 1);
}
return TSDB_CODE_SUCCESS;
}