diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index b7862a96fc93fbe0fde68640df6b6ac313ca9493..b02b8e8484f5371edd3608e5a145b7b0f51d9276 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -5190,7 +5190,11 @@ static bool unique_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pRes if (!function_setup(pCtx, pResInfo)) { return false; } - *pCtx->pUniqueSet = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if(*pCtx->pUniqueSet != NULL){ + taosHashClear(*pCtx->pUniqueSet); + }else{ + *pCtx->pUniqueSet = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + } return true; } diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 2920158b6d24b9a02cf161901678aff61f4b3841..9a4fc2b810d9a9d77ec6c6c662fef6e0ee3dafce 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3688,7 +3688,9 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i RESET_RESULT_INFO(pCellInfo); pCtx[i].resultInfo = pCellInfo; - pCtx[i].pUniqueSet = &pRow->uniqueHash; + if (pCtx[i].functionId == TSDB_FUNC_UNIQUE) { + pCtx[i].pUniqueSet = &pRow->uniqueHash; + } pCtx[i].pOutput = pData->pData; pCtx[i].currentStage = stage; assert(pCtx[i].pOutput != NULL); @@ -4023,7 +4025,9 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe int32_t offset = 0; for (int32_t i = 0; i < numOfOutput; ++i) { pCtx[i].resultInfo = getResultCell(pResult, i, rowCellInfoOffset); - pCtx[i].pUniqueSet = &pResult->uniqueHash; + if (pCtx[i].functionId == TSDB_FUNC_UNIQUE){ + pCtx[i].pUniqueSet = &pResult->uniqueHash; + } SResultRowCellInfo* pResInfo = pCtx[i].resultInfo; if (pResInfo->initialized && pResInfo->complete) { @@ -4117,7 +4121,9 @@ void setResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResult, SQLF * not all queries require the interResultBuf, such as COUNT */ pCtx[i].resultInfo = getResultCell(pResult, i, rowCellInfoOffset); - pCtx[i].pUniqueSet = &pResult->uniqueHash; + if (pCtx[i].functionId == TSDB_FUNC_UNIQUE) { + pCtx[i].pUniqueSet = &pResult->uniqueHash; + } } }