-
Notifications
You must be signed in to change notification settings - Fork 588
[VL] result mismatch found in round #6827
Copy link
Copy link
Open
Labels
Description
Backend
VL (Velox)
Bug description
SQL:
SELECT round(cast(0.5549999999999999 as double), 2);
Gluten returns 0.56, but vanilla spark returns 0.55.
The reason of this mismatch is that the result of std::nextafter(0.5549999999999999) is 0.55500000000000005, which make std::round return 56.
Besides, the following SQL also can't produce the result result in gluten:
SELECT round(cast(0.19324999999999998 as double), 2);
Gluten returns 0.1933, spark returns 0.1922.
I have tried the following modification in round:
return static_cast<TNum>(std::round(std::nextafter(static_cast<long double>(number), kInf) * factor) / factor);
I can fix the first example, but the second example still has a mismatch.
The modification will cause other mismatch:
SELECT round(cast(0.575 as double), 2);
Before the modification, gluten returns the right result, which is 0.58. After the modification, glutens returns 0.57.
Spark version
3.0
Spark configurations
No response
System information
No response
Relevant logs
No response
Reactions are currently unavailable