Merge pull request #12473 from taosdata/feature/3.0_liaohj
fix(query): ignore the reserved column data when generating filtered result.
This commit is contained in:
commit
fe01caf3c8
|
@ -2114,6 +2114,7 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep);
|
||||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
|
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
|
||||||
if (pFilterNode == NULL) {
|
if (pFilterNode == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -2128,43 +2129,60 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
|
||||||
code = filterSetDataFromSlotId(filter, ¶m1);
|
code = filterSetDataFromSlotId(filter, ¶m1);
|
||||||
|
|
||||||
int8_t* rowRes = NULL;
|
int8_t* rowRes = NULL;
|
||||||
|
// todo the keep seems never to be True??
|
||||||
bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols);
|
bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols);
|
||||||
filterFreeInfo(filter);
|
filterFreeInfo(filter);
|
||||||
|
|
||||||
SSDataBlock* px = createOneDataBlock(pBlock, false);
|
extractQualifiedTupleByFilterResult(pBlock, rowRes, keep);
|
||||||
blockDataEnsureCapacity(px, pBlock->info.rows);
|
blockDataUpdateTsWindow(pBlock);
|
||||||
|
}
|
||||||
|
|
||||||
// todo extract method
|
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep) {
|
||||||
int32_t numOfRow = 0;
|
if (keep) {
|
||||||
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
return;
|
||||||
SColumnInfoData* pDst = taosArrayGet(px->pDataBlock, i);
|
}
|
||||||
SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, i);
|
|
||||||
if (keep) {
|
if (rowRes != NULL) {
|
||||||
colDataAssign(pDst, pSrc, pBlock->info.rows);
|
SSDataBlock* px = createOneDataBlock(pBlock, false);
|
||||||
numOfRow = pBlock->info.rows;
|
blockDataEnsureCapacity(px, pBlock->info.rows);
|
||||||
} else if (NULL != rowRes) {
|
|
||||||
numOfRow = 0;
|
int32_t totalRows = pBlock->info.rows;
|
||||||
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
|
||||||
|
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
||||||
|
SColumnInfoData* pDst = taosArrayGet(px->pDataBlock, i);
|
||||||
|
SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
||||||
|
// For the reserved column, the value is not filled yet, so the whole column data may be NULL.
|
||||||
|
if (pSrc->pData == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
for (int32_t j = 0; j < totalRows; ++j) {
|
||||||
if (rowRes[j] == 0) {
|
if (rowRes[j] == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colDataIsNull_s(pSrc, j)) {
|
if (colDataIsNull_s(pSrc, j)) {
|
||||||
colDataAppendNULL(pDst, numOfRow);
|
colDataAppendNULL(pDst, numOfRows);
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pDst, numOfRow, colDataGetData(pSrc, j), false);
|
colDataAppend(pDst, numOfRows, colDataGetData(pSrc, j), false);
|
||||||
}
|
}
|
||||||
numOfRow += 1;
|
numOfRows += 1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
numOfRow = 0;
|
if (pBlock->info.rows == totalRows) {
|
||||||
|
pBlock->info.rows = numOfRows;
|
||||||
|
} else {
|
||||||
|
ASSERT(pBlock->info.rows == numOfRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
*pSrc = *pDst;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
*pSrc = *pDst;
|
// do nothing
|
||||||
|
pBlock->info.rows = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pBlock->info.rows = numOfRow;
|
|
||||||
blockDataUpdateTsWindow(pBlock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, uint64_t groupId,
|
void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, uint64_t groupId,
|
||||||
|
|
Loading…
Reference in New Issue