From ee88f9518245042a9c9de80e1701e1583029f996 Mon Sep 17 00:00:00 2001 From: Deepak Majeti Date: Thu, 6 Jun 2024 08:25:28 +0530 Subject: [PATCH] Fix REAL and DOUBLE hash functions --- velox/connectors/hive/HivePartitionFunction.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/velox/connectors/hive/HivePartitionFunction.cpp b/velox/connectors/hive/HivePartitionFunction.cpp index ad787455abc6f..f2efeeaa506f3 100644 --- a/velox/connectors/hive/HivePartitionFunction.cpp +++ b/velox/connectors/hive/HivePartitionFunction.cpp @@ -76,7 +76,9 @@ inline uint32_t hashOne(const int32_t& value) { template <> inline uint32_t hashOne(const float& value) { - return static_cast(*reinterpret_cast(&value)); + uint32_t ret; + memcpy(&ret, &value, sizeof ret); + return ret; } template <> @@ -86,7 +88,9 @@ inline uint32_t hashOne(const int64_t& value) { template <> inline uint32_t hashOne(const double& value) { - return hashInt64(*reinterpret_cast(&value)); + int64_t val; + memcpy(&val, &value, sizeof val); + return hashInt64(val); } template <>