From a94abd5dae6ee935b0142c9a007b1d59428230ed Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Fri, 10 Jun 2022 21:10:55 +0800 Subject: [PATCH] support merge function resType same as original input type --- source/libs/function/src/builtinsimpl.c | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 36c14f1be1..c2e91c13dc 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -2445,7 +2445,7 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); char* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); - if (pSResInfo->numOfRes != 0 && + if (pSResInfo->numOfRes != 0 && (pDResInfo->numOfRes == 0 || *(TSKEY*)(pDBuf + bytes) < *(TSKEY*)(pSBuf + bytes)) ) { memcpy(pDBuf, pSBuf, bytes); *(TSKEY*)(pDBuf + bytes) = *(TSKEY*)(pSBuf + bytes); @@ -2699,6 +2699,34 @@ int32_t topFunction(SqlFunctionCtx* pCtx) { return TSDB_CODE_SUCCESS; } +static void topBotTransfer(STopBotRes* pInput, STopBotRes* pOutput) { +} + +int32_t topBotFunctionMerge(SqlFunctionCtx *pCtx) { + SInputColumnInfoData* pInput = &pCtx->input; + SColumnInfoData* pCol = pInput->pData[0]; + ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + + STopBotRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + STopBotRes* pInputInfo = (STopBotRes *)varDataVal(data); + + pInfo->hasResult = pInputInfo->hasResult; + if (pInputInfo->max > pInfo->max) { + pInfo->max = pInputInfo->max; + } + + if (pInputInfo->min < pInfo->min) { + pInfo->min = pInputInfo->min; + } + + SET_VAL(GET_RES_INFO(pCtx), 1, 1); + + return TSDB_CODE_SUCCESS; +} + int32_t bottomFunction(SqlFunctionCtx* pCtx) { int32_t numOfElems = 0; SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); -- GitLab