diff --git a/src/Common/HashTable/ClearableHashSet.h b/src/Common/HashTable/ClearableHashSet.h index 87d02f6e8ac..db6a4e487e6 100644 --- a/src/Common/HashTable/ClearableHashSet.h +++ b/src/Common/HashTable/ClearableHashSet.h @@ -90,7 +90,8 @@ public: this->m_size = 0; /// clear ZeroValueStorage - this->clearHasZero(); + if (this->hasZero()) + this->clearHasZero(); } }; @@ -113,7 +114,8 @@ public: this->m_size = 0; /// clear ZeroValueStorage - this->clearHasZero(); + if (this->hasZero()) + this->clearHasZero(); } }; diff --git a/tests/queries/0_stateless/02733_fix_distinct_in_order_bug_49622.sql b/tests/queries/0_stateless/02733_fix_distinct_in_order_bug_49622.sql index b9953226c2a..9501a2c0761 100644 --- a/tests/queries/0_stateless/02733_fix_distinct_in_order_bug_49622.sql +++ b/tests/queries/0_stateless/02733_fix_distinct_in_order_bug_49622.sql @@ -1,8 +1,8 @@ set optimize_distinct_in_order=1; -DROP TABLE IF EXISTS test; +DROP TABLE IF EXISTS test_string; -CREATE TABLE test +CREATE TABLE test_string ( `c1` String, `c2` String @@ -10,6 +10,6 @@ CREATE TABLE test ENGINE = MergeTree ORDER BY c1; -INSERT INTO test(c1, c2) VALUES ('1', ''), ('2', ''); +INSERT INTO test_string(c1, c2) VALUES ('1', ''), ('2', ''); -SELECT DISTINCT c2, c1 FROM test FORMAT TSV; +SELECT DISTINCT c2, c1 FROM test_string;