@@ -460,17 +460,19 @@ bool CompareValueImplFloat(const T& valResult, TStringBuf vExpected) {
460
460
}
461
461
462
462
bool CompareValueImplDecimal (const NYdb::TDecimalValue& valResult, TStringBuf vExpected) {
463
- constexpr double relativeFloatPrecession = 0.0001 ;
464
463
auto resInt = NYql::NDecimal::FromHalfs (valResult.Low_ , valResult.Hi_ );
465
464
TStringBuf precesionStr;
466
465
vExpected.Split (" +-" , vExpected, precesionStr);
467
- auto expectedInt = NYql::NDecimal::FromString (vExpected, 22 , 9 );
466
+ auto expectedInt = NYql::NDecimal::FromString (vExpected, valResult. DecimalType_ . Precision , valResult. DecimalType_ . Scale );
468
467
469
468
if (precesionStr) {
470
- auto precInt = NYql::NDecimal::FromString (precesionStr, 22 , 9 );
469
+ auto precInt = NYql::NDecimal::FromString (precesionStr, valResult. DecimalType_ . Precision , valResult. DecimalType_ . Scale );
471
470
return resInt >= expectedInt - precInt && resInt <= expectedInt + precInt;
472
471
}
473
- return resInt > (1 - relativeFloatPrecession) * expectedInt && resInt < (1 + relativeFloatPrecession) * expectedInt;
472
+ const auto from = NYql::NDecimal::FromString (" 0.9999" , valResult.DecimalType_ .Precision , valResult.DecimalType_ .Scale );
473
+ const auto to = NYql::NDecimal::FromString (" 1.0001" , valResult.DecimalType_ .Precision , valResult.DecimalType_ .Scale );
474
+ const auto devider = NYql::NDecimal::GetDivider (valResult.DecimalType_ .Scale );
475
+ return resInt > NYql::NDecimal::MulAndDivNormalDivider (from, expectedInt, devider) && resInt < NYql::NDecimal::MulAndDivNormalDivider (to, expectedInt, devider);
474
476
}
475
477
476
478
bool CompareValueImplDatetime (const TInstant& valResult, TStringBuf vExpected, TDuration unit) {
0 commit comments