diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 33d85252630882834b95c4ba45840d7d58384b7c..5d3af0440b74f9393091b83de02a7e0b7e849569 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2560,7 +2560,8 @@ static void percentile_finalizer(SQLFunctionCtx *pCtx) { tMemBucket * pMemBucket = ppInfo->pMemBucket; if (pMemBucket == NULL || pMemBucket->total == 0) { // check for null - assert(ppInfo->numOfElems == 0); + if (ppInfo->stage > 0) + assert(ppInfo->numOfElems == 0); setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); } else { SET_DOUBLE_VAL((double *)pCtx->pOutput, getPercentile(pMemBucket, v));