提交 89abd4e3 编写于 作者: G Ganlin Zhao

[TD-14241]: add string functions

上级 b0eefba1
......@@ -478,16 +478,6 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType };
break;
}
case FUNCTION_TYPE_CONCAT:
case FUNCTION_TYPE_ROWTS:
case FUNCTION_TYPE_TBNAME:
case FUNCTION_TYPE_QSTARTTS:
case FUNCTION_TYPE_QENDTS:
case FUNCTION_TYPE_WSTARTTS:
case FUNCTION_TYPE_WENDTS:
case FUNCTION_TYPE_WDURATION:
// todo
break;
case FUNCTION_TYPE_ABS:
case FUNCTION_TYPE_CEIL:
......@@ -512,6 +502,35 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
break;
}
case FUNCTION_TYPE_LENGTH:
case FUNCTION_TYPE_CHAR_LENGTH: {
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_SMALLINT].bytes, .type = TSDB_DATA_TYPE_SMALLINT };
break;
}
case FUNCTION_TYPE_CONCAT:
case FUNCTION_TYPE_CONCAT_WS:
case FUNCTION_TYPE_LOWER:
case FUNCTION_TYPE_UPPER:
case FUNCTION_TYPE_LTRIM:
case FUNCTION_TYPE_RTRIM:
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 };
break;
}
case FUNCTION_TYPE_ROWTS:
case FUNCTION_TYPE_TBNAME:
case FUNCTION_TYPE_QSTARTTS:
case FUNCTION_TYPE_QENDTS:
case FUNCTION_TYPE_WSTARTTS:
case FUNCTION_TYPE_WENDTS:
case FUNCTION_TYPE_WDURATION:
// todo
break;
default:
ASSERT(0); // to found the fault ASAP.
}
......
......@@ -294,7 +294,7 @@ int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
SColumnInfoData *pInputData = pInput->columnData;
SColumnInfoData *pOutputData = pOutput->columnData;
char **in = (char **)pInputData->pData;
char *in = pInputData->pData;
int16_t *out = (int16_t *)pOutputData->pData;
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
......@@ -303,7 +303,8 @@ int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
continue;
}
out[i] = lenFn(in[i], type);
out[i] = lenFn(in, type);
in += varDataTLen(in);
}
pOutput->numOfRows = pInput->numOfRows;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册