From 487f1e0f52e804a46c87f96afa8e4ef93876f767 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 12 Jul 2022 10:55:51 +0800 Subject: [PATCH] enh(query): avg function adoption for MIA operator TD-17254 --- source/libs/function/src/builtinsimpl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 359352951f..404274ee52 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -907,11 +907,13 @@ int32_t avgFunctionMerge(SqlFunctionCtx* pCtx) { SAvgRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t start = pInput->startRowIndex; - char* data = colDataGetData(pCol, start); - SAvgRes* pInputInfo = (SAvgRes*)varDataVal(data); + int32_t start = pInput->startRowIndex; - avgTransferInfo(pInputInfo, pInfo); + for(int32_t i = start; i < start + pInput->numOfRows; ++i) { + char* data = colDataGetData(pCol, i); + SAvgRes* pInputInfo = (SAvgRes*)varDataVal(data); + avgTransferInfo(pInputInfo, pInfo); + } SET_VAL(GET_RES_INFO(pCtx), 1, 1); @@ -4164,10 +4166,10 @@ int32_t histogramFunctionMerge(SqlFunctionCtx* pCtx) { SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t start = pInput->startRowIndex; + int32_t start = pInput->startRowIndex; for(int32_t i = start; i < start + pInput->numOfRows; ++i) { - char* data = colDataGetData(pCol, i); + char* data = colDataGetData(pCol, i); SHistoFuncInfo* pInputInfo = (SHistoFuncInfo*)varDataVal(data); histogramTransferInfo(pInputInfo, pInfo); } -- GitLab