fix: merge spread into output when input spread has result
This commit is contained in:
parent
07b88a35d5
commit
e9f79254fb
|
@ -354,8 +354,6 @@ void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type);
|
|||
void *getDataMin(int32_t type);
|
||||
void *getDataMax(int32_t type);
|
||||
|
||||
#define SET_DOUBLE_NULL(v) (*(uint64_t *)(v) = TSDB_DATA_DOUBLE_NULL)
|
||||
#define SET_BIGINT_NULL(v) (*(uint64_t *)(v) = TSDB_DATA_BIGINT_NULL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ typedef struct SResultRowEntryInfo {
|
|||
bool initialized:1; // output buffer has been initialized
|
||||
bool complete:1; // query has completed
|
||||
uint8_t isNullRes:6; // the result is null
|
||||
uint16_t numOfRes; // num of output result in current buffer
|
||||
uint16_t numOfRes; // num of output result in current buffer. NOT NULL RESULT
|
||||
} SResultRowEntryInfo;
|
||||
|
||||
// determine the real data need to calculated the result
|
||||
|
|
|
@ -3845,14 +3845,17 @@ int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx) {
|
|||
SSpreadInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
|
||||
int32_t start = pInput->startRowIndex;
|
||||
|
||||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||
char* data = colDataGetData(pCol, i);
|
||||
SSpreadInfo* pInputInfo = (SSpreadInfo*)varDataVal(data);
|
||||
spreadTransferInfo(pInputInfo, pInfo);
|
||||
if (pInputInfo->hasResult) {
|
||||
spreadTransferInfo(pInputInfo, pInfo);
|
||||
}
|
||||
}
|
||||
|
||||
SET_VAL(GET_RES_INFO(pCtx), 1, 1);
|
||||
if (pInfo->hasResult) {
|
||||
GET_RES_INFO(pCtx)->numOfRes = 1;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -3861,6 +3864,8 @@ int32_t spreadFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
SSpreadInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
if (pInfo->hasResult == true) {
|
||||
SET_DOUBLE_VAL(&pInfo->result, pInfo->max - pInfo->min);
|
||||
} else {
|
||||
GET_RES_INFO(pCtx)->isNullRes = 1;
|
||||
}
|
||||
return functionFinalize(pCtx, pBlock);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue