From bfa59b8a5b13b2932a31ede323168653e32c14c9 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 18 Aug 2023 15:46:00 +0800 Subject: [PATCH] fix: tbname rewrite issue --- source/libs/planner/src/planLogicCreater.c | 2 ++ source/libs/planner/src/planPhysiCreater.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 0170eb7e8c..1c17db606c 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -434,6 +434,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { SNodeList* pNewScanPseudoCols = NULL; code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM, NULL); +/* if (TSDB_CODE_SUCCESS == code && NULL != pScan->pScanPseudoCols) { code = createColumnByRewriteExprs(pScan->pScanPseudoCols, &pNewScanPseudoCols); if (TSDB_CODE_SUCCESS == code) { @@ -441,6 +442,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect pScan->pScanPseudoCols = pNewScanPseudoCols; } } +*/ } if (NULL != pScan->pScanCols) { diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 5c09e4e223..7e5a40ee0d 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -53,6 +53,17 @@ static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) { return sprintf(pKey, "%s", pCol->colName); } return sprintf(pKey, "%s.%s", pCol->tableAlias, pCol->colName); + } else if (QUERY_NODE_FUNCTION == nodeType(pNode)) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + if (FUNCTION_TYPE_TBNAME == pFunc->funcType) { + SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 0); + if (pVal) { + if (NULL != pStmtName && '\0' != pStmtName[0]) { + return sprintf(pKey, "%s.%s", pStmtName, ((SExprNode*)pNode)->aliasName); + } + return sprintf(pKey, "%s.%s", pVal->literal, ((SExprNode*)pNode)->aliasName); + } + } } if (NULL != pStmtName && '\0' != pStmtName[0]) {