From fd2c374426cfc3dcc018ee4ddcbfe8537f9beeee Mon Sep 17 00:00:00 2001 From: Jerry Hu Date: Tue, 19 Jul 2022 23:25:28 +0800 Subject: [PATCH] [fix]Empty string key in aggregation was output as NULL (#11011) --- be/src/vec/common/hash_table/string_hash_table.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/be/src/vec/common/hash_table/string_hash_table.h b/be/src/vec/common/hash_table/string_hash_table.h index bffd0f1e80..b6e4a04da7 100644 --- a/be/src/vec/common/hash_table/string_hash_table.h +++ b/be/src/vec/common/hash_table/string_hash_table.h @@ -94,9 +94,10 @@ struct StringHashTableEmpty //-V730 public: bool has_zero() const { return _has_zero; } - void set_has_zero() { + void set_has_zero(const typename Cell::key_type& key) { _has_zero = true; new (zero_value()) Cell(); + zero_value()->value.first = key; } void set_has_zero(const Cell& other) { @@ -118,9 +119,11 @@ public: using ConstLookupResult = const Cell*; template - void ALWAYS_INLINE emplace(KeyHolder&&, LookupResult& it, bool& inserted, size_t = 0) { + void ALWAYS_INLINE emplace(KeyHolder&& key_holder, LookupResult& it, bool& inserted, + size_t = 0) { if (!has_zero()) { - set_has_zero(); + const auto& key = key_holder_get_key(key_holder); + set_has_zero(key); inserted = true; } else inserted = false; @@ -467,7 +470,7 @@ public: const size_t sz = x.size; if (sz == 0) { key_holder_discard_key(key_holder); - return func(self.m0, VoidKey {}, 0); + return func(self.m0, std::forward(key_holder), 0); } if (x.data[sz - 1] == 0) {