diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index e37a627f8d9e02a6354c9d84a3e784d65f44b9c0..07a0d357ba5acb7f47e4d019bd50a265bc45d77e 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -3446,7 +3446,11 @@ static int32_t extractQueryResultSchema(const SNodeList* pProjections, int32_t* (*pSchema)[index].type = pExpr->resType.type; (*pSchema)[index].bytes = pExpr->resType.bytes; (*pSchema)[index].colId = index + 1; - strcpy((*pSchema)[index].name, pExpr->userAlias); + if ('\0' != pExpr->userAlias[0]) { + strcpy((*pSchema)[index].name, pExpr->userAlias); + } else { + strcpy((*pSchema)[index].name, pExpr->aliasName); + } index += 1; } diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index 213140806b167fcdfc4ec13305062353f74981a6..688e20063a4f02f3b077b116e1b702c428562c71 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -139,6 +139,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { static EDealRes rewriteQueryExprAliasImpl(SNode* pNode, void* pContext) { if (nodesIsExprNode(pNode) && QUERY_NODE_COLUMN != nodeType(pNode) && '\0' == ((SExprNode*)pNode)->userAlias[0]) { + strcpy(((SExprNode*)pNode)->userAlias, ((SExprNode*)pNode)->aliasName); sprintf(((SExprNode*)pNode)->aliasName, "#%d", *(int32_t*)pContext); ++(*(int32_t*)pContext); }