From 950be95fdfa66fd38be807191c6c502014ca4dc5 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 23 Jul 2022 10:40:58 +0800 Subject: [PATCH] fix(query): fix error in limit/offset --- source/libs/executor/src/executorimpl.c | 33 +++++++++++++++++++------ tests/script/tsim/parser/fill.sim | 1 + 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 2cf45f8ce5..7bac828a53 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3406,12 +3406,13 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { } if (pProjectInfo->mergeDataBlocks) { - if (pFinalRes->info.rows + pInfo->pRes->info.rows <= pOperator->resultInfo.threshold) { - pFinalRes->info.groupId = pInfo->pRes->info.groupId; - pFinalRes->info.version = pInfo->pRes->info.version; + pFinalRes->info.groupId = pInfo->pRes->info.groupId; + pFinalRes->info.version = pInfo->pRes->info.version; + + // continue merge data, ignore the group id + blockDataMerge(pFinalRes, pInfo->pRes); - // continue merge data, ignore the group id - blockDataMerge(pFinalRes, pInfo->pRes); + if (pFinalRes->info.rows + pInfo->pRes->info.rows <= pOperator->resultInfo.threshold) { continue; } } @@ -4246,9 +4247,11 @@ int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, } SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode) { - int32_t numOfCols = LIST_LENGTH(pScanNode->pScanCols); + int32_t numOfCols = LIST_LENGTH(pScanNode->pScanCols); + int32_t numOfTags = LIST_LENGTH(pScanNode->pScanPseudoCols); + SSchemaWrapper* pqSw = taosMemoryCalloc(1, sizeof(SSchemaWrapper)); - pqSw->pSchema = taosMemoryCalloc(numOfCols, sizeof(SSchema)); + pqSw->pSchema = taosMemoryCalloc(numOfCols + numOfTags, sizeof(SSchema)); for (int32_t i = 0; i < numOfCols; ++i) { STargetNode* pNode = (STargetNode*)nodesListGetNode(pScanNode->pScanCols, i); @@ -4261,6 +4264,22 @@ SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode) { strncpy(pSchema->name, pColNode->colName, tListLen(pSchema->name)); } + // this the tags and pseudo function columns, we only keep the tag columns + for(int32_t i = 0; i < numOfTags; ++i) { + STargetNode* pNode = (STargetNode*)nodesListGetNode(pScanNode->pScanPseudoCols, i); + + int32_t type = nodeType(pNode->pExpr); + if (type == QUERY_NODE_COLUMN) { + SColumnNode* pColNode = (SColumnNode*)pNode->pExpr; + + SSchema* pSchema = &pqSw->pSchema[pqSw->nCols++]; + pSchema->colId = pColNode->colId; + pSchema->type = pColNode->node.resType.type; + pSchema->type = pColNode->node.resType.bytes; + strncpy(pSchema->name, pColNode->colName, tListLen(pSchema->name)); + } + } + return pqSw; } diff --git a/tests/script/tsim/parser/fill.sim b/tests/script/tsim/parser/fill.sim index 698314fa36..396bdd1e56 100644 --- a/tests/script/tsim/parser/fill.sim +++ b/tests/script/tsim/parser/fill.sim @@ -960,6 +960,7 @@ endi sql select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 4:2:15' interval(500a) fill(value, 99,91,90,89,88,87,86,85) ; if $rows != 21749 then + print expect 21749, actual: $rows return -1 endi -- GitLab