fix: correct rowindex is used to retrieve selectivity values from source block when first/last function merge
This commit is contained in:
parent
1cbd1f4c5f
commit
b880d460ec
|
@ -2977,10 +2977,9 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst) {
|
||||
static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst, int32_t rowIndex) {
|
||||
SInputColumnInfoData* pColInfo = &pCtx->input;
|
||||
|
||||
int32_t start = pColInfo->startRowIndex;
|
||||
if (pOutput->hasResult) {
|
||||
if (isFirst) {
|
||||
if (pInput->ts > pOutput->ts) {
|
||||
|
@ -2998,7 +2997,7 @@ static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, S
|
|||
pOutput->bytes = pInput->bytes;
|
||||
|
||||
memcpy(pOutput->buf, pInput->buf, pOutput->bytes);
|
||||
firstlastSaveTupleData(pCtx->pSrcBlock, start, pCtx, pOutput);
|
||||
firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pOutput);
|
||||
|
||||
pOutput->hasResult = true;
|
||||
}
|
||||
|
@ -3016,7 +3015,7 @@ static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuer
|
|||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||
char* data = colDataGetData(pCol, i);
|
||||
SFirstLastRes* pInputInfo = (SFirstLastRes*)varDataVal(data);
|
||||
firstLastTransferInfo(pCtx, pInputInfo, pInfo, isFirstQuery);
|
||||
firstLastTransferInfo(pCtx, pInputInfo, pInfo, isFirstQuery, i);
|
||||
if (!numOfElems) {
|
||||
numOfElems = pInputInfo->hasResult ? 1 : 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue