Revert "fix: LEASTSQUARES func result overflow"

This commit is contained in:
xinsheng Ren 2024-01-17 10:09:56 +08:00 committed by GitHub
parent a56e589048
commit 737abbebb7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 13 deletions

View File

@ -1576,13 +1576,9 @@ int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
param12 /= param[1][1]; param12 /= param[1][1];
char buf[64] = {0}; char buf[512] = {0};
size_t len = 0; size_t len =
if (fabs(param02) > 1e6 || fabs(param12) > 1e6) { snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", param02, param12);
len = snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6e, intercept:%.6e}", param02, param12);
} else {
len = snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", param02, param12);
}
varDataSetLen(buf, len); varDataSetLen(buf, len);
colDataSetVal(pCol, currentRow, buf, pResInfo->isNullRes); colDataSetVal(pCol, currentRow, buf, pResInfo->isNullRes);

View File

@ -2428,12 +2428,8 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa
matrix12 /= matrix[1][1]; matrix12 /= matrix[1][1];
char buf[64] = {0}; char buf[64] = {0};
size_t len = 0; size_t len = snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", matrix02,
if (fabs(matrix02) > 1e6 || fabs(matrix12) > 1e6) { matrix12);
len = snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6e, intercept:%.6e}", matrix02, matrix12);
} else {
len = snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", matrix02, matrix12);
}
varDataSetLen(buf, len); varDataSetLen(buf, len);
colDataSetVal(pOutputData, 0, buf, false); colDataSetVal(pOutputData, 0, buf, false);
} }