[td-3188]

This commit is contained in:
Haojun Liao 2021-03-19 09:51:53 +08:00
parent 18cb7b36fc
commit 0d8dcc2972
2 changed files with 29 additions and 7 deletions

View File

@ -1073,7 +1073,6 @@ static void doExecuteFinalMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bool n
}
pCtx->currentStage = MERGE_STAGE;
if (needInit) {
aAggs[pCtx->functionId].init(pCtx, pCtx->resultInfo);
}

View File

@ -782,8 +782,14 @@ static void doApplyFunctions(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx
}
if (functionNeedToExecute(pRuntimeEnv, &pCtx[k], functionId)) {
// aAggs[functionId].xFunction(&pCtx[k]);
if (functionId < 0) {
// load the script and exec, pRuntimeEnv->pUdfInfo
} else {
aAggs[functionId].xFunction(&pCtx[k]);
}
}
// restore it
pCtx[k].preAggVals.isSet = hasPrev;
@ -1009,9 +1015,15 @@ static void doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SQLFunction
int32_t functionId = pCtx[k].functionId;
if (functionNeedToExecute(pRuntimeEnv, &pCtx[k], functionId)) {
pCtx[k].startTs = startTs;// this can be set during create the struct
// aAggs[functionId].xFunction(&pCtx[k]);
if (functionId < 0) {
// load the script and exec, pRuntimeEnv->pUdfInfo
} else {
aAggs[functionId].xFunction(&pCtx[k]);
}
}
}
}
static void arithmeticApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx *pCtx, int32_t numOfOutput) {
@ -1019,8 +1031,14 @@ static void arithmeticApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionC
for (int32_t k = 0; k < numOfOutput; ++k) {
pCtx[k].startTs = pQuery->window.skey;
if (pCtx[k].functionId < 0) {
// load the script and exec, pRuntimeEnv->pUdfInfo
} else {
aAggs[pCtx[k].functionId].xFunction(&pCtx[k]);
}
}
}
void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SArray* pDataBlock, TSKEY prevTs,
@ -2480,11 +2498,16 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData
int32_t colId = pTableScanInfo->pExpr[i].base.colInfo.colId;
// group by + first/last should not apply the first/last block filter
if (functionId < 0) {
status |= BLK_DATA_ALL_NEEDED;
return status;
} else {
status |= aAggs[functionId].dataReqFunc(&pTableScanInfo->pCtx[i], &pBlock->info.window, colId);
if ((status & BLK_DATA_ALL_NEEDED) == BLK_DATA_ALL_NEEDED) {
return status;
}
}
}
return status;
}
@ -3060,7 +3083,7 @@ void initCtxOutputBuffer(SQLFunctionCtx* pCtx, int32_t size) {
continue;
}
if (pCtx[j].functionId < 0) { // udf initialize
if (pCtx[j].functionId < 0) { // todo udf initialization
} else {
aAggs[pCtx[j].functionId].init(&pCtx[j], pCtx[j].resultInfo);