From 334f0911f104b39c292bb201b5e187276aa6918a Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 20 Dec 2021 16:27:16 +0800 Subject: [PATCH] [TD-12276]: elapsed nest query: Return a negative calculation result --- src/query/src/qAggMain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index e033650b74..3dc89cb196 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -4870,7 +4870,8 @@ static void elapsedFinalizer(SQLFunctionCtx *pCtx) { } SElapsedInfo *pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - *(double *)pCtx->pOutput = (double)pInfo->max - (double)pInfo->min; + double result = (double)pInfo->max - (double)pInfo->min; + *(double *)pCtx->pOutput = result >= 0 ? result : -result; if (pCtx->numOfParams > 0 && pCtx->param[0].i64 > 0) { *(double *)pCtx->pOutput = *(double *)pCtx->pOutput / pCtx->param[0].i64; } -- GitLab