diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 972421b1e7..98f0a795f7 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -536,6 +536,9 @@ int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc); const char* operatorTypeStr(EOperatorType type); const char* logicConditionTypeStr(ELogicConditionType type); +bool nodesIsStar(SNode* pNode); +bool nodesIsTableStar(SNode* pNode); + #ifdef __cplusplus } #endif diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index a9de910b98..bf5b6c8080 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -2337,4 +2337,14 @@ SValueNode* nodesMakeValueNodeFromBool(bool b) { pValNode->isNull = false; } return pValNode; +} + +bool nodesIsStar(SNode* pNode) { + return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' == ((SColumnNode*)pNode)->tableAlias[0]) && + (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); +} + +bool nodesIsTableStar(SNode* pNode) { + return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' != ((SColumnNode*)pNode)->tableAlias[0]) && + (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); } \ No newline at end of file diff --git a/source/libs/parser/inc/parTranslater.h b/source/libs/parser/inc/parTranslater.h index ca21429167..553123da99 100644 --- a/source/libs/parser/inc/parTranslater.h +++ b/source/libs/parser/inc/parTranslater.h @@ -47,8 +47,6 @@ typedef struct STranslateContext { } STranslateContext; int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect); -bool isStar(SNode* pNode); -bool isTableStar(SNode* pNode); #ifdef __cplusplus } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index d5845834db..8f066307dc 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1789,17 +1789,8 @@ static int32_t translateBlockDistFunc(STranslateContext* pCtx, SFunctionNode* pF return TSDB_CODE_SUCCESS; } -bool isStar(SNode* pNode) { - return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' == ((SColumnNode*)pNode)->tableAlias[0]) && - (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); -} -bool isTableStar(SNode* pNode) { - return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' != ((SColumnNode*)pNode)->tableAlias[0]) && - (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); -} - -static bool isStarParam(SNode* pNode) { return isStar(pNode) || isTableStar(pNode); } +static bool isStarParam(SNode* pNode) { return nodesIsStar(pNode) || nodesIsTableStar(pNode); } static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { if (!fmIsMultiResFunc(pFunc->funcId)) { @@ -2917,9 +2908,9 @@ static int32_t createMultiResFuncsParas(STranslateContext* pCxt, SNodeList* pSrc SNodeList* pExprs = NULL; SNode* pPara = NULL; FOREACH(pPara, pSrcParas) { - if (isStar(pPara)) { + if (nodesIsStar(pPara)) { code = createAllColumns(pCxt, true, &pExprs); - } else if (isTableStar(pPara)) { + } else if (nodesIsTableStar(pPara)) { code = createTableAllCols(pCxt, (SColumnNode*)pPara, true, &pExprs); } else { code = nodesListMakeStrictAppend(&pExprs, nodesCloneNode(pPara)); @@ -3012,7 +3003,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) { SNode* pNode = NULL; WHERE_EACH(pNode, pSelect->pProjectionList) { int32_t code = TSDB_CODE_SUCCESS; - if (isStar(pNode)) { + if (nodesIsStar(pNode)) { SNodeList* pCols = NULL; code = createAllColumns(pCxt, false, &pCols); if (TSDB_CODE_SUCCESS == code) { @@ -3032,7 +3023,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) { ERASE_NODE(pSelect->pProjectionList); continue; } - } else if (isTableStar(pNode)) { + } else if (nodesIsTableStar(pNode)) { SNodeList* pCols = NULL; code = createTableAllCols(pCxt, (SColumnNode*)pNode, false, &pCols); if (TSDB_CODE_SUCCESS == code) {