提交 77d2737f 编写于 作者: G Ganlin Zhao

fix: fix userAlias issue when keepColumnName is set to true

上级 05c7ec61
......@@ -52,6 +52,7 @@ typedef struct SExprNode {
SArray* pAssociation;
bool orderAlias;
bool asAlias;
bool asParam;
} SExprNode;
typedef enum EColumnType {
......
......@@ -214,6 +214,18 @@ void nodesWalkExprsPostOrder(SNodeList* pList, FNodeWalker walker, void* pContex
(void)walkExprs(pList, TRAVERSAL_POSTORDER, walker, pContext);
}
static void checkParamIsFunc(SFunctionNode *pFunc) {
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
if (numOfParams > 1) {
for (int32_t i = 0; i < numOfParams; ++i) {
SNode* pPara = nodesListGetNode(pFunc->pParameterList, i);
if (nodeType(pPara) == QUERY_NODE_FUNCTION) {
((SFunctionNode *)pPara)->node.asParam = true;
}
}
}
}
static EDealRes rewriteExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeRewriter rewriter, void* pContext);
static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewriter rewriter, void* pContext) {
......@@ -248,9 +260,12 @@ static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
case QUERY_NODE_LOGIC_CONDITION:
res = rewriteExprs(((SLogicConditionNode*)pNode)->pParameterList, order, rewriter, pContext);
break;
case QUERY_NODE_FUNCTION:
res = rewriteExprs(((SFunctionNode*)pNode)->pParameterList, order, rewriter, pContext);
case QUERY_NODE_FUNCTION: {
SFunctionNode* pFunc = (SFunctionNode*)pNode;
checkParamIsFunc(pFunc);
res = rewriteExprs(pFunc->pParameterList, order, rewriter, pContext);
break;
}
case QUERY_NODE_REAL_TABLE:
case QUERY_NODE_TEMP_TABLE:
break; // todo
......
......@@ -1760,7 +1760,7 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu
"%s(*) is only supported in SELECTed list", pFunc->functionName);
}
}
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias) {
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias && !pFunc->node.asParam) {
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
strcpy(pFunc->node.aliasName, pFunc->node.userAlias);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册