From 6730cb5041e9369282a7c08f4345c4da06e9e973 Mon Sep 17 00:00:00 2001 From: lgbo-ustc Date: Mon, 1 Jul 2024 20:26:14 +0800 Subject: [PATCH] ensure same results from NaN --- cpp-ch/local-engine/Functions/SparkFunctionHashingExtended.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp-ch/local-engine/Functions/SparkFunctionHashingExtended.h b/cpp-ch/local-engine/Functions/SparkFunctionHashingExtended.h index 82d678aa2a4e..57bf00ba9904 100644 --- a/cpp-ch/local-engine/Functions/SparkFunctionHashingExtended.h +++ b/cpp-ch/local-engine/Functions/SparkFunctionHashingExtended.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace DB { @@ -200,14 +201,14 @@ class SparkFunctionAnyHash : public IFunction { if constexpr (std::is_same_v) { - if (n == -0.0f) [[unlikely]] + if (n == -0.0f || isNaN(n)) [[unlikely]] return applyNumber(0, seed); else return Impl::apply(reinterpret_cast(&n), sizeof(n), seed); } else { - if (n == -0.0) [[unlikely]] + if (n == -0.0 || isNaN(n)) [[unlikely]] return applyNumber(0, seed); else return Impl::apply(reinterpret_cast(&n), sizeof(n), seed);