mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Revert old UUID hash used for partition ID.
This commit is contained in:
parent
9a652e6aba
commit
12791431da
@ -269,6 +269,18 @@ public:
|
||||
void operator() (const AggregateFunctionStateData & x) const;
|
||||
};
|
||||
|
||||
/// This is a special visitor which is used to get partition ID.
|
||||
/// Calculate hash for UUID the same way as for UInt128.
|
||||
/// It worked this way until 21.5, and we cannot change it,
|
||||
/// or partition ID will be different in case UUID is used in partiton key.
|
||||
/// (It is not recommended to use UUID as partition key).
|
||||
class LegacyFieldVisitorHash : public FieldVisitorHash
|
||||
{
|
||||
public:
|
||||
using FieldVisitorHash::FieldVisitorHash;
|
||||
void operator() (const UUID & x) const { FieldVisitorHash::operator()(x.toUnderType()); }
|
||||
};
|
||||
|
||||
|
||||
template <typename T> constexpr bool isDecimalField() { return false; }
|
||||
template <> constexpr bool isDecimalField<DecimalField<Decimal32>>() { return true; }
|
||||
|
@ -74,7 +74,7 @@ String MergeTreePartition::getID(const Block & partition_key_sample) const
|
||||
}
|
||||
|
||||
SipHash hash;
|
||||
FieldVisitorHash hashing_visitor(hash);
|
||||
LegacyFieldVisitorHash hashing_visitor(hash);
|
||||
for (const Field & field : value)
|
||||
applyVisitor(hashing_visitor, field);
|
||||
|
||||
|
1
tests/queries/0_stateless/01891_partition_hash.reference
Normal file
1
tests/queries/0_stateless/01891_partition_hash.reference
Normal file
@ -0,0 +1 @@
|
||||
6ba51fa36c625adab5d58007c96e32bf
|
7
tests/queries/0_stateless/01891_partition_hash.sql
Normal file
7
tests/queries/0_stateless/01891_partition_hash.sql
Normal file
@ -0,0 +1,7 @@
|
||||
drop table if exists tab;
|
||||
create table tab (i8 Int8, i16 Int16, i32 Int32, i64 Int64, i128 Int128, i256 Int256, u8 UInt8, u16 UInt16, u32 UInt32, u64 UInt64, u128 UInt128, u256 UInt256, id UUID, s String, fs FixedString(33), a Array(UInt8), t Tuple(UInt16, UInt32), d Date, dt DateTime, dt64 DateTime64, dec128 Decimal128(3), dec256 Decimal256(4), lc LowCardinality(String)) engine = MergeTree PARTITION BY (i8, i16, i32, i64, i128, i256, u8, u16, u32, u64, u128, u256, id, s, fs, a, t, d, dt, dt64, dec128, dec256, lc) order by tuple();
|
||||
insert into tab values (-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, '61f0c404-5cb3-11e7-907b-a6006ad3dba0', 'a', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', [1, 2, 3], (-1, -2), '2020-01-01', '2020-01-01 01:01:01', '2020-01-01 01:01:01', '123.456', '78.9101', 'a');
|
||||
-- Here we check that partition id did not change.
|
||||
-- Different result means Backward Incompatible Change. Old partitions will not be accepted by new server.
|
||||
select partition_id from system.parts where table = 'tab' and database = currentDatabase();
|
||||
drop table if exists tab;
|
@ -0,0 +1 @@
|
||||
04a875063d3809312ff884e90a5b4dad
|
@ -0,0 +1,7 @@
|
||||
drop table if exists tab;
|
||||
create table tab (i8 Int8, i16 Int16, i32 Int32, i64 Int64, u8 UInt8, u16 UInt16, u32 UInt32, u64 UInt64, id UUID, s String, fs FixedString(33), a Array(UInt8), t Tuple(UInt16, UInt32), d Date, dt DateTime, dt64 DateTime64, dec128 Decimal128(3), lc LowCardinality(String)) engine = MergeTree PARTITION BY (i8, i16, i32, i64, u8, u16, u32, u64, id, s, fs, a, t, d, dt, dt64, dec128, lc) order by tuple();
|
||||
insert into tab values (-1, -1, -1, -1, -1, -1, -1, -1, '61f0c404-5cb3-11e7-907b-a6006ad3dba0', 'a', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', [1, 2, 3], (-1, -2), '2020-01-01', '2020-01-01 01:01:01', '2020-01-01 01:01:01', '123.456', 'a');
|
||||
-- Here we check that partition id did not change.
|
||||
-- Different result means Backward Incompatible Change. Old partitions will not be accepted by new server.
|
||||
select partition_id from system.parts where table = 'tab' and database = currentDatabase();
|
||||
drop table if exists tab;
|
Loading…
Reference in New Issue
Block a user