From 5bb0cde59c4de1f89d2c7b00316c952302f32ed8 Mon Sep 17 00:00:00 2001 From: chertus Date: Wed, 7 Aug 2019 16:53:46 +0300 Subject: [PATCH] hotfix for Decimal.compareAt --- dbms/src/Columns/ColumnDecimal.cpp | 2 +- .../0_stateless/00880_decimal_in_key.reference | 2 ++ .../queries/0_stateless/00880_decimal_in_key.sql | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/00880_decimal_in_key.reference create mode 100644 dbms/tests/queries/0_stateless/00880_decimal_in_key.sql diff --git a/dbms/src/Columns/ColumnDecimal.cpp b/dbms/src/Columns/ColumnDecimal.cpp index 55c22884144..73b0ee282d6 100644 --- a/dbms/src/Columns/ColumnDecimal.cpp +++ b/dbms/src/Columns/ColumnDecimal.cpp @@ -26,7 +26,7 @@ namespace ErrorCodes template int ColumnDecimal::compareAt(size_t n, size_t m, const IColumn & rhs_, int) const { - auto other = static_cast(rhs_); + auto & other = static_cast(rhs_); const T & a = data[n]; const T & b = other.data[m]; diff --git a/dbms/tests/queries/0_stateless/00880_decimal_in_key.reference b/dbms/tests/queries/0_stateless/00880_decimal_in_key.reference new file mode 100644 index 00000000000..fcd78da1283 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00880_decimal_in_key.reference @@ -0,0 +1,2 @@ +1000000 +1000000 diff --git a/dbms/tests/queries/0_stateless/00880_decimal_in_key.sql b/dbms/tests/queries/0_stateless/00880_decimal_in_key.sql new file mode 100644 index 00000000000..44edf725a41 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00880_decimal_in_key.sql @@ -0,0 +1,14 @@ +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1 (str String, dec Decimal64(8)) ENGINE = MergeTree ORDER BY str; +CREATE TABLE t2 (str String, dec Decimal64(8)) ENGINE = MergeTree ORDER BY dec; + +INSERT INTO t1 SELECT toString(number), toDecimal64(number, 8) FROM system.numbers LIMIT 1000000; +SELECT count() FROM t1; + +INSERT INTO t2 SELECT toString(number), toDecimal64(number, 8) FROM system.numbers LIMIT 1000000; +SELECT count() FROM t2; + +DROP TABLE t1; +DROP TABLE t2;