From 89bd2f478c4f91eaae5fc680d9c842fbc8501569 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index c4d99b2e62..33b675cfc6 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -2547,6 +2547,14 @@ void vectorTimeFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn } else if (pInputs[j].type == TSDB_DATA_TYPE_BIGINT || pInputs[j].type == TSDB_DATA_TYPE_TIMESTAMP) { /* unix timestamp or ts column*/ GET_TYPED_DATA(timeVal[j], int64_t, pInputs[j].type, inputData[j]); + if (pInputs[j].type == TSDB_DATA_TYPE_TIMESTAMP) { + int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : + (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); + int64_t timeValSec = timeVal[j] / factor; + if (timeValSec < 1000000000) { + timeVal[j] = timeValSec; + } + } char buf[20] = {0}; NUM_TO_STRING(TSDB_DATA_TYPE_BIGINT, &timeVal[j], sizeof(buf), buf); int32_t tsDigits = strlen(buf); -- GitLab