diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 0a6f366e79857ba3b9da0a07deacb83cc42aa599..5e5fe91aaffbef987d141761ea1b1e955dc67341 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -471,6 +471,7 @@ typedef struct SProjectOperatorInfo { int32_t bufCapacity; uint32_t seed; uint32_t order; + bool updateTableQueryInfo; SSDataBlock *existDataBlock; } SProjectOperatorInfo; @@ -592,7 +593,7 @@ SOperatorInfo* createTableScanOperator(void* pTsdbQueryHandle, SQueryRuntimeEnv* SOperatorInfo* createTableSeqScanOperator(void* pTsdbQueryHandle, SQueryRuntimeEnv* pRuntimeEnv); SOperatorInfo* createAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); -SOperatorInfo* createProjectOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, uint32_t order); +SOperatorInfo* createProjectOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, uint32_t order, bool UpdateTableQueryInfo); SOperatorInfo* createLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream); SOperatorInfo* createTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createAllTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 62f565c4d5b053d644cb3d20f88d2cff8dca1569..1120f531b4c2fac2d9e998a823fa261e4a02160f 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -2262,19 +2262,19 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf case OP_Project: { // TODO refactor to remove arith operator. SOperatorInfo* prev = pRuntimeEnv->proot; if (i == 0) { - pRuntimeEnv->proot = createProjectOperatorInfo(pRuntimeEnv, prev, pQueryAttr->pExpr1, pQueryAttr->numOfOutput, pQueryAttr->order.order); + pRuntimeEnv->proot = createProjectOperatorInfo(pRuntimeEnv, prev, pQueryAttr->pExpr1, pQueryAttr->numOfOutput, pQueryAttr->order.order, true); if (pRuntimeEnv->proot != NULL && prev->operatorType != OP_DummyInput && prev->operatorType != OP_Join) { // TODO refactor setTableScanFilterOperatorInfo(prev->info, pRuntimeEnv->proot); } } else { prev = pRuntimeEnv->proot; assert(pQueryAttr->pExpr2 != NULL); - if (prev->operatorType == OP_Project) { + if (prev->operatorType == OP_Project || pQueryAttr->stableQuery) { pRuntimeEnv->proot = - createProjectOperatorInfo(pRuntimeEnv, prev, pQueryAttr->pExpr2, pQueryAttr->numOfExpr2, TSDB_ORDER_ASC); + createProjectOperatorInfo(pRuntimeEnv, prev, pQueryAttr->pExpr2, pQueryAttr->numOfExpr2, TSDB_ORDER_ASC, false); } else { pRuntimeEnv->proot = - createProjectOperatorInfo(pRuntimeEnv, prev, pQueryAttr->pExpr2, pQueryAttr->numOfExpr2, pQueryAttr->order.order); + createProjectOperatorInfo(pRuntimeEnv, prev, pQueryAttr->pExpr2, pQueryAttr->numOfExpr2, pQueryAttr->order.order, true); } } break; @@ -5837,7 +5837,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) { updateOutputBuf(&pProjectInfo->binfo, &pProjectInfo->bufCapacity, pBlock->info.rows); projectApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput); - if (pTableQueryInfo != NULL) { + if (pTableQueryInfo != NULL && pProjectInfo->updateTableQueryInfo) { updateTableIdInfo(pTableQueryInfo, pBlock, pRuntimeEnv->pTableRetrieveTsMap, pRuntimeEnv->pQueryAttr->order.order); } @@ -5898,7 +5898,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) { updateOutputBuf(&pProjectInfo->binfo, &pProjectInfo->bufCapacity, pBlock->info.rows); projectApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput); - if (pTableQueryInfo != NULL) { + if (pTableQueryInfo != NULL && pProjectInfo->updateTableQueryInfo) { updateTableIdInfo(pTableQueryInfo, pBlock, pRuntimeEnv->pTableRetrieveTsMap, pRuntimeEnv->pQueryAttr->order.order); } @@ -6751,12 +6751,14 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SO return pOperator; } -SOperatorInfo* createProjectOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, uint32_t order) { +SOperatorInfo* createProjectOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, + SExprInfo* pExpr, int32_t numOfOutput, uint32_t order, bool updateTableQueryInfo) { SProjectOperatorInfo* pInfo = calloc(1, sizeof(SProjectOperatorInfo)); pInfo->seed = rand(); pInfo->bufCapacity = pRuntimeEnv->resultInfo.capacity; pInfo->order = order; + pInfo->updateTableQueryInfo = updateTableQueryInfo; SOptrBasicInfo* pBInfo = &pInfo->binfo; pBInfo->pRes = createOutputBuf(pExpr, numOfOutput, pInfo->bufCapacity);