fix(query): fix the invalid return value check for percentile function.
This commit is contained in:
parent
e0dbe22199
commit
3a848ccb36
|
@ -1662,6 +1662,8 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||
SVariant* pVal = &pCtx->param[1].param;
|
||||
terrno = 0;
|
||||
|
||||
double v = 0;
|
||||
GET_TYPED_DATA(v, double, pVal->nType, &pVal->i);
|
||||
|
||||
|
@ -1675,8 +1677,8 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
|
||||
tMemBucketDestroy(pMemBucket);
|
||||
|
||||
if (ppInfo->result < 0) {
|
||||
return TSDB_CODE_NO_AVAIL_DISK;
|
||||
if (terrno != TSDB_CODE_SUCCESS) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return functionFinalize(pCtx, pBlock);
|
||||
|
|
|
@ -92,6 +92,7 @@ static void resetPosInfo(SSlotInfo *pInfo) {
|
|||
|
||||
double findOnlyResult(tMemBucket *pMemBucket) {
|
||||
ASSERT(pMemBucket->total == 1);
|
||||
terrno = 0;
|
||||
|
||||
for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) {
|
||||
tMemBucketSlot *pSlot = &pMemBucket->pSlots[i];
|
||||
|
@ -108,8 +109,10 @@ double findOnlyResult(tMemBucket *pMemBucket) {
|
|||
int32_t *pageId = taosArrayGet(list, 0);
|
||||
SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId);
|
||||
if (pPage == NULL) {
|
||||
return -1;
|
||||
terrno = TSDB_CODE_NO_AVAIL_DISK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ASSERT(pPage->num == 1);
|
||||
|
||||
double v = 0;
|
||||
|
@ -546,9 +549,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
|
|||
|
||||
// if only one elements exists, return it
|
||||
if (pMemBucket->total == 1) {
|
||||
if (findOnlyResult(pMemBucket) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return findOnlyResult(pMemBucket);
|
||||
}
|
||||
|
||||
percent = fabs(percent);
|
||||
|
|
Loading…
Reference in New Issue