diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index f8fd18d90a38b18f49e6822e9c1c666a2553c4fa..d015b4cf11c34da66a8483e6ed43e0977b0dce27 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -323,8 +323,10 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI return TSDB_CODE_SUCCESS; } else if (functionId == TSDB_FUNC_SAMPLE) { *type = TSDB_DATA_TYPE_BINARY; - *bytes = (int16_t)(sizeof(SSampleFuncInfo) + sizeof(dataBytes) * param + sizeof(int64_t) * param); + *bytes = (int16_t)(sizeof(SSampleFuncInfo) + dataBytes * param + sizeof(int64_t) * param); *interBytes = *bytes; + + return TSDB_CODE_SUCCESS; } else if (functionId == TSDB_FUNC_SPREAD) { *type = TSDB_DATA_TYPE_BINARY; *bytes = sizeof(SSpreadInfo); @@ -4774,6 +4776,8 @@ static void sample_func_merge(SQLFunctionCtx *pCtx) { pInput->timeStamps = (int64_t*)((char*)pInput->values + pInput->colBytes * pCtx->param[0].i64); SSampleFuncInfo *pOutput = getSampleFuncOutputInfo(pCtx); + pOutput->totalPoints = pInput->totalPoints; + pOutput->numSampled = pInput->numSampled; for (int32_t i = 0; i < pInput->numSampled; ++i) { assignResultSample(pOutput, i, pInput->timeStamps[i], pInput->values + i * pInput->colBytes, pCtx->outputType, pInput->colBytes); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 1eb353ad468a20b34a5264eb50232ea3c3a95a90..8d1f523574d48d90fe19d8c7b00c0c732244d1d1 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3924,7 +3924,8 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe continue; } - if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { + if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF || + functionId == TSDB_FUNC_CSUM || functionId == TSDB_FUNC_MAVG || functionId == TSDB_FUNC_SAMPLE) { if(i > 0) pCtx[i].ptsOutputBuf = pCtx[i-1].pOutput; } @@ -7928,7 +7929,7 @@ static int32_t updateOutputBufForTopBotQuery(SQueriedTableInfo* pTableInfo, SCol for (int32_t i = 0; i < numOfOutput; ++i) { int16_t functId = pExprs[i].base.functionId; - if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) { + if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM || functId == TSDB_FUNC_SAMPLE) { int32_t j = getColumnIndexInSource(pTableInfo, &pExprs[i].base, pTagCols); if (j < 0 || j >= pTableInfo->numOfCols) { return TSDB_CODE_QRY_INVALID_MSG;