提交 58c43901 编写于 作者: K kailixu

chore: another logic

上级 1812b9e9
......@@ -3108,6 +3108,12 @@ static int32_t rewriteProjectAlias(SNodeList* pProjectionList) {
if ('\0' == pExpr->userAlias[0]) {
strcpy(pExpr->userAlias, pExpr->aliasName);
}
if (QUERY_NODE_COLUMN == nodeType(pProject) &&
((0 == strcasecmp("_wstart", pExpr->userAlias) || 0 == strcasecmp("_wend", pExpr->userAlias) ||
0 == strcasecmp("_wduration", pExpr->userAlias)) &&
'\0' != pExpr->aliasName[0])) {
continue;
}
sprintf(pExpr->aliasName, "#expr_%d", no++);
}
return TSDB_CODE_SUCCESS;
......
......@@ -732,49 +732,6 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
return code;
}
static int32_t eraseDuplicatedPseudoColumnFuncs(SNodeList* pFuncs, SNodeList* pProjections) {
int32_t code = 0;
int32_t funcIndex = 0;
SSHashObj* pFuncHash = NULL;
SNode* pFuncNode = NULL;
FOREACH(pFuncNode, pFuncs) {
SFunctionNode* pFunc = (SFunctionNode*)pFuncNode;
if (!fmIsWindowPseudoColumnFunc(pFunc->funcId)) {
++funcIndex;
continue;
}
if (!pFuncHash && !(pFuncHash = tSimpleHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT)))) {
code = TSDB_CODE_OUT_OF_MEMORY;
break;
}
void* hashVal = tSimpleHashGet(pFuncHash, &pFunc->funcId, sizeof(pFunc->funcId));
if (!hashVal) {
tSimpleHashPut(pFuncHash, &pFunc->funcId, sizeof(pFunc->funcId), &funcIndex, sizeof(funcIndex));
++funcIndex;
continue;
}
bool exist = false;
SNode* pProject = NULL;
FOREACH(pProject, pProjections) {
if (QUERY_NODE_COLUMN == nodeType(pProject) && 0 != pFunc->node.aliasName[0] &&
0 == strncmp(pFunc->node.aliasName, ((SColumnNode*)pProject)->colName, TSDB_COL_NAME_LEN)) {
exist = true;
break;
}
}
if (!exist) {
nodesListErase(pFuncs, nodesListGetCell(pFuncs, funcIndex));
} else {
nodesListErase(pFuncs, nodesListGetCell(pFuncs, *(int32_t*)hashVal));
tSimpleHashPut(pFuncHash, &pFunc->funcId, sizeof(pFunc->funcId), &funcIndex, sizeof(funcIndex));
}
}
tSimpleHashCleanup(pFuncHash);
return code;
}
static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SWindowLogicNode* pWindow,
SLogicNode** pLogicNode) {
if (pCxt->pPlanCxt->streamQuery) {
......@@ -792,11 +749,6 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
code = rewriteExprsForSelect(pWindow->pFuncs, pSelect, SQL_CLAUSE_WINDOW, NULL);
}
if (TSDB_CODE_SUCCESS == code && WINDOW_TYPE_INTERVAL == pWindow->winType && pSelect->pProjectionList) {
// erase duplicated Window Pseudo funcNode by filtering colNode in pSelect->pProjectionList
code = eraseDuplicatedPseudoColumnFuncs(pWindow->pFuncs, pSelect->pProjectionList);
}
if (TSDB_CODE_SUCCESS == code) {
code = createColumnByRewriteExprs(pWindow->pFuncs, &pWindow->node.pTargets);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册