Skip to content

Commit

Permalink
ensure same results from NaN (apache#6301)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgbo-ustc authored Jul 2, 2024
1 parent 5d6d214 commit 15c99ba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cpp-ch/local-engine/Functions/SparkFunctionHashingExtended.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/NumberTraits.h>
#include <Functions/FunctionsHashing.h>
#include <Common/NaNUtils.h>

namespace DB
{
Expand Down Expand Up @@ -200,14 +201,14 @@ class SparkFunctionAnyHash : public IFunction
{
if constexpr (std::is_same_v<T, Float32>)
{
if (n == -0.0f) [[unlikely]]
if (n == -0.0f || isNaN(n)) [[unlikely]]
return applyNumber<Int32>(0, seed);
else
return Impl::apply(reinterpret_cast<const char *>(&n), sizeof(n), seed);
}
else
{
if (n == -0.0) [[unlikely]]
if (n == -0.0 || isNaN(n)) [[unlikely]]
return applyNumber<Int64>(0, seed);
else
return Impl::apply(reinterpret_cast<const char *>(&n), sizeof(n), seed);
Expand Down

0 comments on commit 15c99ba

Please sign in to comment.