fix: alias name length

This commit is contained in:
facetosea 2025-02-18 00:20:40 +08:00
parent 9d86f48622
commit 8a7b633036
3 changed files with 10 additions and 8 deletions

View File

@ -55,8 +55,8 @@ typedef struct SDataType {
typedef struct SExprNode {
ENodeType type;
SDataType resType;
char aliasName[TSDB_COL_NAME_LEN];
char userAlias[TSDB_COL_NAME_LEN];
char aliasName[TSDB_COL_NAME_LEN + TSDB_COL_NAME_EXLEN];
char userAlias[TSDB_COL_NAME_LEN + TSDB_COL_NAME_EXLEN];
SArray* pAssociation;
bool asAlias;
bool asParam;

View File

@ -15,6 +15,7 @@
#include "filter.h"
#include "function.h"
#include "nodes.h"
#include "os.h"
#include "querynodes.h"
#include "tfill.h"
@ -395,10 +396,12 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc
return TSDB_CODE_SUCCESS;
}
// if the last expression is a tuple function, we don't need to create a empty data block
int32_t lastExprIndex = pOperator->exprSupp.numOfExprs - 1;
if(pOperator->exprSupp.pExprInfo[lastExprIndex].pExpr->_function.bindExprID > 0) {
return TSDB_CODE_SUCCESS;
// if the expression is a bind expression, we don't need to create a empty data block
for (int i = pOperator->exprSupp.numOfExprs - 1; i >= 0; i--) {
SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[i];
if (nodeType(pExprInfo->pExpr) == QUERY_NODE_FUNCTION && pExprInfo->pExpr->_function.bindExprID > 0) {
return TSDB_CODE_SUCCESS;
}
}
code = createDataBlock(&pBlock);

View File

@ -3585,8 +3585,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
if (isRelatedToOtherExpr((SExprNode*)*pNode)) {
int len = strlen(((SExprNode*)*pNode)->aliasName);
if (len + TSDB_COL_NAME_EXLEN >= TSDB_COL_NAME_LEN) {
parserError("%s The alias name is too long, the extra part will be truncated", __func__);
return DEAL_RES_ERROR;
parserWarn("%s The alias name is too long, the extra part will be truncated", __func__);
}
tsnprintf(pFunc->node.aliasName + len, TSDB_COL_NAME_EXLEN, ".%d", ((SExprNode*)*pNode)->relatedTo);
}