From a73f29ca2e8941adc7acf8b6efbb06d03f7387ad Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Tue, 12 Feb 2019 17:38:29 +0300 Subject: [PATCH 1/3] Fix LowCardinality cache. --- dbms/src/Common/ColumnsHashing.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dbms/src/Common/ColumnsHashing.h b/dbms/src/Common/ColumnsHashing.h index 4f6708ae2f1..436ed43660e 100644 --- a/dbms/src/Common/ColumnsHashing.h +++ b/dbms/src/Common/ColumnsHashing.h @@ -364,7 +364,10 @@ struct HashMethodSingleLowCardinalityColumn : public SingleColumnMethod } if constexpr (has_mapped) + { + mapped_cache[row] = it->second; return EmplaceResult(it->second, mapped_cache[row], inserted); + } else return EmplaceResult(inserted); } From b95f5196c0f9fab7d4e076f41000c6610396e19f Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Tue, 12 Feb 2019 17:43:52 +0300 Subject: [PATCH 2/3] Added test. --- .../queries/0_stateless/906_low_cardinality_cache.reference | 1 + dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/906_low_cardinality_cache.reference create mode 100644 dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql diff --git a/dbms/tests/queries/0_stateless/906_low_cardinality_cache.reference b/dbms/tests/queries/0_stateless/906_low_cardinality_cache.reference new file mode 100644 index 00000000000..5e2be7a023a --- /dev/null +++ b/dbms/tests/queries/0_stateless/906_low_cardinality_cache.reference @@ -0,0 +1 @@ +100000000 0123456789 diff --git a/dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql b/dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql new file mode 100644 index 00000000000..cafc559d77f --- /dev/null +++ b/dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql @@ -0,0 +1,5 @@ +drop table if exists test.lc; +create table test.lc (b LowCardinality(String)) engine=MergeTree order by b; +insert into test.lc select '0123456789' from numbers(100000000); +select count(), b from test.lc group by b; + From 7673d2abb5c2385d7e0fbd7d046d40fa455f786a Mon Sep 17 00:00:00 2001 From: KochetovNicolai Date: Tue, 12 Feb 2019 18:48:32 +0300 Subject: [PATCH 3/3] Update 906_low_cardinality_cache.sql Delete table after test. --- dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql b/dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql index cafc559d77f..ca286e9379f 100644 --- a/dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql +++ b/dbms/tests/queries/0_stateless/906_low_cardinality_cache.sql @@ -2,4 +2,4 @@ drop table if exists test.lc; create table test.lc (b LowCardinality(String)) engine=MergeTree order by b; insert into test.lc select '0123456789' from numbers(100000000); select count(), b from test.lc group by b; - +drop table if exists test.lc;