From dafa42eb180460096d0738e912a2cd2b803758cc Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 21 Sep 2021 09:25:09 +0800 Subject: [PATCH] fix sample group by tbname error --- src/query/src/qAggMain.c | 6 +++++- src/query/src/qExecutor.c | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index f8fd18d90a..d015b4cf11 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 1eb353ad46..8d1f523574 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; -- GitLab