From d6dde36c4530b87b627776c59c6115ef8882236a Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 22 Feb 2022 17:29:52 +0800 Subject: [PATCH] "[TD-11220](query): time related functions" --- src/common/src/texpr.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 9e22b2d437..5542f8ff5b 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -2326,7 +2326,21 @@ void vectorTimeFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn int64_t timeVal = 0; int64_t timePrec; GET_TYPED_DATA(timePrec, int64_t, pInputs[1].type, inputData[1]); - taosParseTime((char *)varDataVal(inputData[0]), &timeVal, pInputs[0].bytes, timePrec, 0); + if (pInputs[0].type == TSDB_DATA_TYPE_BINARY) { + taosParseTime((char *)varDataVal(inputData[0]), &timeVal, pInputs[0].bytes, timePrec, 0); + } else { + int32_t charLen = varDataLen(inputData[0]); + char *newColData = calloc(1, charLen / TSDB_NCHAR_SIZE + 1); + int len = taosUcs4ToMbs(varDataVal(inputData[0]), charLen, newColData); + if (len < 0){ + uError("vectorTimeFunc taosUcs4ToMbs error 1"); + tfree(newColData); + return; + } + newColData[len] = 0; + taosParseTime(newColData, &timeVal, len + 1, timePrec, 0); + tfree(newColData); + } SET_TYPED_DATA(outputData, pOutput->type, timeVal); break; -- GitLab