From 737abbebb748e26d7ad1b058b699b998b63600dd Mon Sep 17 00:00:00 2001 From: xinsheng Ren <285808407@qq.com> Date: Wed, 17 Jan 2024 10:09:56 +0800 Subject: [PATCH] Revert "fix: LEASTSQUARES func result overflow" --- source/libs/function/src/builtinsimpl.c | 10 +++------- source/libs/scalar/src/sclfunc.c | 8 ++------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 8dfca36a15..1e71954278 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -1576,13 +1576,9 @@ int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { param12 /= param[1][1]; - char buf[64] = {0}; - size_t len = 0; - if (fabs(param02) > 1e6 || fabs(param12) > 1e6) { - 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); - } + char buf[512] = {0}; + size_t len = + snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", param02, param12); varDataSetLen(buf, len); colDataSetVal(pCol, currentRow, buf, pResInfo->isNullRes); diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 500a126b64..e713043b80 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -2428,12 +2428,8 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa matrix12 /= matrix[1][1]; char buf[64] = {0}; - size_t len = 0; - if (fabs(matrix02) > 1e6 || fabs(matrix12) > 1e6) { - 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); - } + size_t len = snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", matrix02, + matrix12); varDataSetLen(buf, len); colDataSetVal(pOutputData, 0, buf, false); }