diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 168863d322e03888d32122611c93baa1149b92dc..fff8823a83c2d2b6a47a5ad8baf3b189d73bac44 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -396,10 +396,6 @@ static void function_finalizer(SQLFunctionCtx *pCtx) { doFinalizer(pCtx); } -static bool usePreVal(SQLFunctionCtx *pCtx) { - return pCtx->preAggVals.isSet && pCtx->size == pCtx->preAggVals.size; -} - /* * count function does need the finalize, if data is missing, the default value, which is 0, is used * count function does not use the pCtx->interResBuf to keep the intermediate buffer @@ -412,7 +408,7 @@ static void count_function(SQLFunctionCtx *pCtx) { * 2. for general non-primary key columns, pCtx->hasNull may be true or false, pCtx->preAggVals.isSet == true; * 3. for primary key column, pCtx->hasNull always be false, pCtx->preAggVals.isSet == false; */ - if (usePreVal(pCtx)) { + if (pCtx->preAggVals.isSet) { numOfElem = pCtx->size - pCtx->preAggVals.statis.numOfNull; } else { if (pCtx->hasNull) { @@ -537,7 +533,7 @@ static void do_sum(SQLFunctionCtx *pCtx) { int32_t notNullElems = 0; // Only the pre-computing information loaded and actual data does not loaded - if (pCtx->preAggVals.isSet && pCtx->preAggVals.size == pCtx->size) { + if (pCtx->preAggVals.isSet) { notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; assert(pCtx->size >= pCtx->preAggVals.statis.numOfNull); @@ -768,7 +764,7 @@ static void avg_function(SQLFunctionCtx *pCtx) { SAvgInfo *pAvgInfo = (SAvgInfo *)pResInfo->interResultBuf; double * pVal = &pAvgInfo->sum; - if (usePreVal(pCtx)) { + if (pCtx->preAggVals.isSet) { // Pre-aggregation notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; assert(notNullElems >= 0); @@ -932,7 +928,7 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) { static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, int32_t *notNullElems) { // data in current data block are qualified to the query - if (usePreVal(pCtx)) { + if (pCtx->preAggVals.isSet) { *notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; assert(*notNullElems >= 0); @@ -2916,7 +2912,7 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) { } static void date_col_output_function(SQLFunctionCtx *pCtx) { - if (pCtx->scanFlag == REVERSE_SCAN) { + if (pCtx->scanFlag == REVERSE_SCAN) { // todo : remove it return; } @@ -3423,7 +3419,7 @@ static void spread_function(SQLFunctionCtx *pCtx) { // todo : opt with pre-calculated result // column missing cause the hasNull to be true - if (usePreVal(pCtx)) { + if (pCtx->preAggVals.isSet) { numOfElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; // all data are null in current data block, ignore current data block diff --git a/src/query/inc/tsqlfunction.h b/src/query/inc/tsqlfunction.h index a11c03f2c0da8db902d6f24ba70fea56b37385f2..6e591b28d2e607ec7fa9eec81e9e0eef2757491b 100644 --- a/src/query/inc/tsqlfunction.h +++ b/src/query/inc/tsqlfunction.h @@ -126,7 +126,6 @@ typedef struct SArithmeticSupport { typedef struct SQLPreAggVal { bool isSet; - int32_t size; SDataStatis statis; } SQLPreAggVal; @@ -174,7 +173,6 @@ typedef struct SQLFunctionCtx { int16_t outputBytes; // size of results, determined by function and input column data type bool hasNull; // null value exist in current block int16_t functionId; // function id - int32_t blockStatus; // Indicate if data is loaded, it is first/last/internal block. Only for file blocks void * aInputElemBuf; char * aOutputBuf; // final result output buffer, point to sdata->data uint8_t currentStage; // record current running step, default: 0 diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index e9f1ffb49f740f254eb73622133ced2dfc8ab54d..5ef2f128ad26d95e9a23af1a234351e2ba1af09d 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -1342,14 +1342,13 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void *inputData, TSKEY if (pStatis != NULL) { pCtx->preAggVals.isSet = true; - pCtx->preAggVals.size = size; pCtx->preAggVals.statis = *pStatis; } else { pCtx->preAggVals.isSet = false; } pCtx->startOffset = QUERY_IS_ASC_QUERY(pQuery) ? pQuery->pos : 0; - pCtx->size = QUERY_IS_ASC_QUERY(pQuery) ? size - pQuery->pos : pQuery->pos + 1; + pCtx->size = size; uint32_t status = aAggs[functionId].nStatus; if (((status & (TSDB_FUNCSTATE_SELECTIVITY | TSDB_FUNCSTATE_NEED_TS)) != 0) && (tsCol != NULL)) { @@ -1377,6 +1376,8 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void *inputData, TSKEY } else if (functionId == TSDB_FUNC_ARITHM) { pCtx->param[1].pz = param; + } else if (functionId == TSDB_FUNC_SPREAD) { + pCtx-> } #if defined(_DEBUG_VIEW)