Merge pull request #16748 from taosdata/szhou/fixbugs
fix: add _wstart when _wstart does not appear in select projection list
This commit is contained in:
commit
053df87def
|
@ -126,6 +126,7 @@ SArray* extractPartitionColInfo(SNodeList* pNodeList);
|
||||||
SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols,
|
SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols,
|
||||||
int32_t type);
|
int32_t type);
|
||||||
|
|
||||||
|
void createExprFromTargetNode(SExprInfo* pExp, STargetNode* pTargetNode);
|
||||||
SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs);
|
SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs);
|
||||||
|
|
||||||
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowEntryInfoOffset);
|
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowEntryInfoOffset);
|
||||||
|
|
|
@ -1011,30 +1011,7 @@ static SColumn* createColumn(int32_t blockId, int32_t slotId, int32_t colId, SDa
|
||||||
return pCol;
|
return pCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs) {
|
void createExprFromTargetNode(SExprInfo* pExp, STargetNode* pTargetNode) {
|
||||||
int32_t numOfFuncs = LIST_LENGTH(pNodeList);
|
|
||||||
int32_t numOfGroupKeys = 0;
|
|
||||||
if (pGroupKeys != NULL) {
|
|
||||||
numOfGroupKeys = LIST_LENGTH(pGroupKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
*numOfExprs = numOfFuncs + numOfGroupKeys;
|
|
||||||
if (*numOfExprs == 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SExprInfo* pExprs = taosMemoryCalloc(*numOfExprs, sizeof(SExprInfo));
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < (*numOfExprs); ++i) {
|
|
||||||
STargetNode* pTargetNode = NULL;
|
|
||||||
if (i < numOfFuncs) {
|
|
||||||
pTargetNode = (STargetNode*)nodesListGetNode(pNodeList, i);
|
|
||||||
} else {
|
|
||||||
pTargetNode = (STargetNode*)nodesListGetNode(pGroupKeys, i - numOfFuncs);
|
|
||||||
}
|
|
||||||
|
|
||||||
SExprInfo* pExp = &pExprs[i];
|
|
||||||
|
|
||||||
pExp->pExpr = taosMemoryCalloc(1, sizeof(tExprNode));
|
pExp->pExpr = taosMemoryCalloc(1, sizeof(tExprNode));
|
||||||
pExp->pExpr->_function.num = 1;
|
pExp->pExpr->_function.num = 1;
|
||||||
pExp->pExpr->_function.functionId = -1;
|
pExp->pExpr->_function.functionId = -1;
|
||||||
|
@ -1126,6 +1103,32 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs) {
|
||||||
|
int32_t numOfFuncs = LIST_LENGTH(pNodeList);
|
||||||
|
int32_t numOfGroupKeys = 0;
|
||||||
|
if (pGroupKeys != NULL) {
|
||||||
|
numOfGroupKeys = LIST_LENGTH(pGroupKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
*numOfExprs = numOfFuncs + numOfGroupKeys;
|
||||||
|
if (*numOfExprs == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SExprInfo* pExprs = taosMemoryCalloc(*numOfExprs, sizeof(SExprInfo));
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < (*numOfExprs); ++i) {
|
||||||
|
STargetNode* pTargetNode = NULL;
|
||||||
|
if (i < numOfFuncs) {
|
||||||
|
pTargetNode = (STargetNode*)nodesListGetNode(pNodeList, i);
|
||||||
|
} else {
|
||||||
|
pTargetNode = (STargetNode*)nodesListGetNode(pGroupKeys, i - numOfFuncs);
|
||||||
|
}
|
||||||
|
|
||||||
|
SExprInfo* pExp = &pExprs[i];
|
||||||
|
createExprFromTargetNode(pExp, pTargetNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pExprs;
|
return pExprs;
|
||||||
|
|
|
@ -3439,6 +3439,44 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isWstartColumnExist(SFillOperatorInfo* pInfo) {
|
||||||
|
if (pInfo->numOfNotFillExpr == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < pInfo->numOfNotFillExpr; ++i) {
|
||||||
|
SExprInfo* exprInfo = pInfo->pNotFillExprInfo + i;
|
||||||
|
if (exprInfo->pExpr->nodeType == QUERY_NODE_COLUMN &&
|
||||||
|
exprInfo->base.numOfParams == 1 &&
|
||||||
|
exprInfo->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_START) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t createWStartTsAsNotFillExpr(SFillOperatorInfo* pInfo, SFillPhysiNode* pPhyFillNode) {
|
||||||
|
bool wstartExist = isWstartColumnExist(pInfo);
|
||||||
|
if (wstartExist == false) {
|
||||||
|
if (pPhyFillNode->pWStartTs->type != QUERY_NODE_TARGET) {
|
||||||
|
qError("pWStartTs of fill physical node is not a target node");
|
||||||
|
return TSDB_CODE_QRY_SYS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
SExprInfo* notFillExprs = taosMemoryRealloc(pInfo->pNotFillExprInfo, (pInfo->numOfNotFillExpr + 1) * sizeof(SExprInfo));
|
||||||
|
if (notFillExprs == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
createExprFromTargetNode(notFillExprs + pInfo->numOfNotFillExpr, (STargetNode*)pPhyFillNode->pWStartTs);
|
||||||
|
|
||||||
|
++pInfo->numOfNotFillExpr;
|
||||||
|
pInfo->pNotFillExprInfo = notFillExprs;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode,
|
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode,
|
||||||
SExecTaskInfo* pTaskInfo) {
|
SExecTaskInfo* pTaskInfo) {
|
||||||
SFillOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SFillOperatorInfo));
|
SFillOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SFillOperatorInfo));
|
||||||
|
@ -3450,7 +3488,10 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc);
|
||||||
SExprInfo* pExprInfo = createExprInfo(pPhyFillNode->pFillExprs, NULL, &pInfo->numOfExpr);
|
SExprInfo* pExprInfo = createExprInfo(pPhyFillNode->pFillExprs, NULL, &pInfo->numOfExpr);
|
||||||
pInfo->pNotFillExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &pInfo->numOfNotFillExpr);
|
pInfo->pNotFillExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &pInfo->numOfNotFillExpr);
|
||||||
|
int32_t code = createWStartTsAsNotFillExpr(pInfo, pPhyFillNode);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
SInterval* pInterval =
|
SInterval* pInterval =
|
||||||
QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == downstream->operatorType
|
QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == downstream->operatorType
|
||||||
? &((SMergeAlignedIntervalAggOperatorInfo*)downstream->info)->intervalAggOperatorInfo->interval
|
? &((SMergeAlignedIntervalAggOperatorInfo*)downstream->info)->intervalAggOperatorInfo->interval
|
||||||
|
@ -3471,7 +3512,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
|
||||||
SArray* pColMatchColInfo = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc,
|
SArray* pColMatchColInfo = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc,
|
||||||
&numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
&numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
||||||
|
|
||||||
int32_t code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pInfo->pNotFillExprInfo, pInfo->numOfNotFillExpr,
|
code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pInfo->pNotFillExprInfo, pInfo->numOfNotFillExpr,
|
||||||
(SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, pResultInfo->capacity,
|
(SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, pResultInfo->capacity,
|
||||||
pTaskInfo->id.str, pInterval, type, order);
|
pTaskInfo->id.str, pInterval, type, order);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
Loading…
Reference in New Issue