From 6f6d0e4a0997d2c592e07fefcab16d8829c6c608 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Wed, 30 Mar 2022 14:03:54 +0800 Subject: [PATCH] [TD-14241]: concat function adoption --- source/libs/function/src/builtins.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index a18386aff6..a19acb096d 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -508,7 +508,22 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) { break; } - case FUNCTION_TYPE_CONCAT: + case FUNCTION_TYPE_CONCAT: { + int32_t paraTypeFirst, totalBytes = 0; + for (int32_t i = 0; i < pFunc->pParameterList->length; ++i) { + SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, i); + int32_t paraType = pParam->node.resType.type; + if (i == 0) { + paraTypeFirst = paraType; + } + if (paraType != paraTypeFirst) { + return TSDB_CODE_FAILED; + } + totalBytes += pParam->node.resType.bytes; + } + pFunc->node.resType = (SDataType) { .bytes = totalBytes, .type = paraTypeFirst }; + break; + } case FUNCTION_TYPE_CONCAT_WS: case FUNCTION_TYPE_LOWER: case FUNCTION_TYPE_UPPER: @@ -517,7 +532,8 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) { case FUNCTION_TYPE_SUBSTR: { SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0); int32_t paraType = pParam->node.resType.type; - pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType }; + //pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType }; + pFunc->node.resType = (SDataType) { .bytes = 23, .type = paraType }; break; }