diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 6e341de962..9270b0da4e 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3297,6 +3297,7 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) { int8_t* rowRes = NULL; bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols); + filterFreeInfo(filter); SSDataBlock* px = createOneDataBlock(pBlock); blockDataEnsureCapacity(px, pBlock->info.rows); @@ -3306,19 +3307,25 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) { for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { SColumnInfoData* pDst = taosArrayGet(px->pDataBlock, i); SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, i); + if (keep) { + colDataAssign(pDst, pSrc, pBlock->info.rows); + numOfRow = pBlock->info.rows; + } else if (NULL != rowRes) { + numOfRow = 0; + for (int32_t j = 0; j < pBlock->info.rows; ++j) { + if (rowRes[j] == 0) { + continue; + } - numOfRow = 0; - for (int32_t j = 0; j < pBlock->info.rows; ++j) { - if (rowRes[j] == 0) { - continue; + if (colDataIsNull_s(pSrc, j)) { + colDataAppendNULL(pDst, numOfRow); + } else { + colDataAppend(pDst, numOfRow, colDataGetData(pSrc, j), false); + } + numOfRow += 1; } - - if (colDataIsNull_s(pSrc, j)) { - colDataAppendNULL(pDst, numOfRow); - } else { - colDataAppend(pDst, numOfRow, colDataGetData(pSrc, j), false); - } - numOfRow += 1; + } else { + numOfRow = 0; } *pSrc = *pDst; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index c95be2f99d..9eb37d7667 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -597,6 +597,7 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) { int8_t* rowRes = NULL; bool keep = filterExecute(filter, pInfo->pRes, &rowRes, NULL, param1.numOfCols); + filterFreeInfo(filter); SSDataBlock* px = createOneDataBlock(pInfo->pRes); blockDataEnsureCapacity(px, pInfo->pRes->info.rows); @@ -607,14 +608,21 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) { SColumnInfoData* pDest = taosArrayGet(px->pDataBlock, i); SColumnInfoData* pSrc = taosArrayGet(pInfo->pRes->pDataBlock, i); - numOfRow = 0; - for (int32_t j = 0; j < pInfo->pRes->info.rows; ++j) { - if (rowRes[j] == 0) { - continue; + if (keep) { + colDataAssign(pDest, pSrc, pInfo->pRes->info.rows); + numOfRow = pInfo->pRes->info.rows; + } else if (NULL != rowRes) { + numOfRow = 0; + for (int32_t j = 0; j < pInfo->pRes->info.rows; ++j) { + if (rowRes[j] == 0) { + continue; + } + + colDataAppend(pDest, numOfRow, colDataGetData(pSrc, j), false); + numOfRow += 1; } - - colDataAppend(pDest, numOfRow, colDataGetData(pSrc, j), false); - numOfRow += 1; + } else { + numOfRow = 0; } } diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 16236fc05b..c780ed5725 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1797,6 +1797,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { } else { SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; out.columnData->info.type = type; + out.columnData->info.bytes = tDataTypes[type].bytes; // todo refactor the convert int32_t code = doConvertDataType(var, &out); @@ -1804,6 +1805,8 @@ int32_t fltInitValFieldData(SFilterInfo *info) { qError("convert value to type[%d] failed", type); return TSDB_CODE_TSC_INVALID_OPERATION; } + + memcpy(fi->data, out.columnData->pData, out.columnData->info.bytes); } } @@ -3638,6 +3641,10 @@ int32_t fltGetDataFromSlotId(void *param, int32_t id, void **data) { int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param) { + if (NULL == info) { + return TSDB_CODE_QRY_INVALID_INPUT; + } + return fltSetColFieldDataImpl(info, param, fltGetDataFromSlotId, false); } @@ -3691,6 +3698,10 @@ _return: } bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { + if (NULL == info) { + return false; + } + if (info->scalarMode) { SScalarParam output = {0}; diff --git a/tests/script/tsim/query/stddev.sim b/tests/script/tsim/query/stddev.sim index 01cde31966..adab1c354d 100644 --- a/tests/script/tsim/query/stddev.sim +++ b/tests/script/tsim/query/stddev.sim @@ -121,4 +121,4 @@ if $rows != 0 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT