[TD-14241]<feature>: substr function refactor
This commit is contained in:
parent
98cc544e5b
commit
76d1702213
|
@ -559,29 +559,6 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
|
|||
}
|
||||
pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType };
|
||||
break;
|
||||
//int32_t paraTypeFirst, totalBytes = 0, sepBytes = 0;
|
||||
//int32_t firstParamIndex = 0;
|
||||
//if (pFunc->funcType == FUNCTION_TYPE_CONCAT_WS) {
|
||||
// firstParamIndex = 1;
|
||||
// SColumnNode* pSep = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
// sepBytes = pSep->node.resType.type;
|
||||
//}
|
||||
//for (int32_t i = firstParamIndex; i < pFunc->pParameterList->length; ++i) {
|
||||
// SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, i);
|
||||
// int32_t paraType = pParam->node.resType.type;
|
||||
// if (i == firstParamIndex) {
|
||||
// paraTypeFirst = paraType;
|
||||
// }
|
||||
// if (paraType != paraTypeFirst) {
|
||||
// return TSDB_CODE_FAILED;
|
||||
// }
|
||||
// //TODO: for constants also needs numOfRows
|
||||
// totalBytes += pParam->node.resType.bytes;
|
||||
//}
|
||||
////TODO: need to get numOfRows to decide how much space separator needed. Currently set to 100.
|
||||
//totalBytes += sepBytes * (pFunc->pParameterList->length - 2) * 100;
|
||||
//pFunc->node.resType = (SDataType) { .bytes = totalBytes, .type = paraTypeFirst };
|
||||
//break;
|
||||
}
|
||||
case FUNCTION_TYPE_LOWER:
|
||||
case FUNCTION_TYPE_UPPER:
|
||||
|
|
|
@ -609,7 +609,7 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
char *input = pInputData->pData;
|
||||
char *output = NULL;
|
||||
|
||||
int32_t outputLen = pInputData->varmeta.length;
|
||||
int32_t outputLen = pInputData->varmeta.length * pInput->numOfRows;
|
||||
char *outputBuf = taosMemoryCalloc(outputLen, 1);
|
||||
output = outputBuf;
|
||||
|
||||
|
@ -630,12 +630,12 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
startPosBytes = MAX(startPosBytes, 0);
|
||||
}
|
||||
|
||||
subLen = MIN(subLen, len - startPosBytes);
|
||||
if (subLen > 0) {
|
||||
memcpy(varDataVal(output), varDataVal(input) + startPosBytes, subLen);
|
||||
int32_t resLen = MIN(subLen, len - startPosBytes);
|
||||
if (resLen > 0) {
|
||||
memcpy(varDataVal(output), varDataVal(input) + startPosBytes, resLen);
|
||||
}
|
||||
|
||||
varDataSetLen(output, subLen);
|
||||
varDataSetLen(output, resLen);
|
||||
colDataAppend(pOutputData, i , output, false);
|
||||
input += varDataTLen(input);
|
||||
output += varDataTLen(output);
|
||||
|
|
Loading…
Reference in New Issue