From c2a536910ef417ba11f9b000f7083993dbc38aa4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 7 Jan 2021 11:39:13 +0800 Subject: [PATCH] [TD-2610]: null data return nothing in case of stddev query. --- src/query/src/qAggMain.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 2997d56326..98531e1750 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -1268,12 +1268,14 @@ static void min_function_f(SQLFunctionCtx *pCtx, int32_t index) { } static void stddev_function(SQLFunctionCtx *pCtx) { - // the second stage to calculate standard deviation SStddevInfo *pStd = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - if (pStd->stage == 0) { // the first stage is to calculate average value + if (pStd->stage == 0) { + // the first stage is to calculate average value avg_function(pCtx); - } else { + } else if (pStd->num > 0) { + // the second stage to calculate standard deviation + // if pStd->num == 0, there are no numbers in the first round check. No need to do the second round double *retVal = &pStd->res; double avg = pStd->avg; -- GitLab