Merge pull request #20127 from taosdata/fix/TD-22733
fix: percentile finalize wrong error code issue
This commit is contained in:
commit
f9188351d7
|
@ -1689,53 +1689,50 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
double v = 0;
|
double v = 0;
|
||||||
|
|
||||||
tMemBucket* pMemBucket = ppInfo->pMemBucket;
|
tMemBucket* pMemBucket = ppInfo->pMemBucket;
|
||||||
if (pMemBucket == NULL || pMemBucket->total == 0) { // check for null
|
if (pMemBucket != NULL && pMemBucket->total > 0) { // check for null
|
||||||
code = TSDB_CODE_FAILED;
|
if (pCtx->numOfParams > 2) {
|
||||||
goto _fin_error;
|
char buf[512] = {0};
|
||||||
}
|
size_t len = 1;
|
||||||
|
|
||||||
if (pCtx->numOfParams > 2) {
|
varDataVal(buf)[0] = '[';
|
||||||
char buf[512] = {0};
|
for (int32_t i = 1; i < pCtx->numOfParams; ++i) {
|
||||||
size_t len = 1;
|
SVariant* pVal = &pCtx->param[i].param;
|
||||||
|
|
||||||
varDataVal(buf)[0] = '[';
|
GET_TYPED_DATA(v, double, pVal->nType, &pVal->i);
|
||||||
for (int32_t i = 1; i < pCtx->numOfParams; ++i) {
|
|
||||||
SVariant* pVal = &pCtx->param[i].param;
|
int32_t code = getPercentile(pMemBucket, v, &ppInfo->result);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _fin_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == pCtx->numOfParams - 1) {
|
||||||
|
len += snprintf(varDataVal(buf) + len, sizeof(buf) - VARSTR_HEADER_SIZE - len, "%.6lf]", ppInfo->result);
|
||||||
|
} else {
|
||||||
|
len += snprintf(varDataVal(buf) + len, sizeof(buf) - VARSTR_HEADER_SIZE - len, "%.6lf, ", ppInfo->result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||||
|
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
|
||||||
|
varDataSetLen(buf, len);
|
||||||
|
colDataAppend(pCol, pBlock->info.rows, buf, false);
|
||||||
|
|
||||||
|
tMemBucketDestroy(pMemBucket);
|
||||||
|
return pResInfo->numOfRes;
|
||||||
|
} else {
|
||||||
|
SVariant* pVal = &pCtx->param[1].param;
|
||||||
|
|
||||||
GET_TYPED_DATA(v, double, pVal->nType, &pVal->i);
|
GET_TYPED_DATA(v, double, pVal->nType, &pVal->i);
|
||||||
|
|
||||||
int32_t code = getPercentile(pMemBucket, v, &ppInfo->result);
|
code = getPercentile(pMemBucket, v, &ppInfo->result);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _fin_error;
|
goto _fin_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == pCtx->numOfParams - 1) {
|
tMemBucketDestroy(pMemBucket);
|
||||||
len += snprintf(varDataVal(buf) + len, sizeof(buf) - VARSTR_HEADER_SIZE - len, "%.6lf]", ppInfo->result);
|
return functionFinalize(pCtx, pBlock);
|
||||||
} else {
|
|
||||||
len += snprintf(varDataVal(buf) + len, sizeof(buf) - VARSTR_HEADER_SIZE - len, "%.6lf, ", ppInfo->result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
|
||||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
|
||||||
|
|
||||||
varDataSetLen(buf, len);
|
|
||||||
colDataAppend(pCol, pBlock->info.rows, buf, false);
|
|
||||||
|
|
||||||
tMemBucketDestroy(pMemBucket);
|
|
||||||
return pResInfo->numOfRes;
|
|
||||||
} else {
|
|
||||||
SVariant* pVal = &pCtx->param[1].param;
|
|
||||||
|
|
||||||
GET_TYPED_DATA(v, double, pVal->nType, &pVal->i);
|
|
||||||
|
|
||||||
code = getPercentile(pMemBucket, v, &ppInfo->result);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
goto _fin_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
tMemBucketDestroy(pMemBucket);
|
|
||||||
return functionFinalize(pCtx, pBlock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_fin_error:
|
_fin_error:
|
||||||
|
|
Loading…
Reference in New Issue