diff --git a/src/Functions/generateUUIDv4.cpp b/src/Functions/generateUUIDv4.cpp index 160afc7ea64..7ca127857df 100644 --- a/src/Functions/generateUUIDv4.cpp +++ b/src/Functions/generateUUIDv4.cpp @@ -32,21 +32,22 @@ public: ColumnPtr executeImpl(const ColumnsWithTypeAndName &, const DataTypePtr &, size_t input_rows_count) const override { - auto col_res = ColumnVector::create(); - typename ColumnVector::Container & vec_to = col_res->getData(); + auto col_res = ColumnVector::create(); + typename ColumnVector::Container & vec_to = col_res->getData(); size_t size = input_rows_count; vec_to.resize(size); /// RandImpl is target-dependent and is not the same in different TargetSpecific namespaces. - RandImpl::execute(reinterpret_cast(vec_to.data()), vec_to.size() * sizeof(UInt128)); + RandImpl::execute(reinterpret_cast(vec_to.data()), vec_to.size() * sizeof(UUID)); - for (UInt128 & uuid: vec_to) + for (UUID & uuid : vec_to) { - /** https://tools.ietf.org/html/rfc4122#section-4.4 - */ - uuid.items[0] = (uuid.items[0] & 0xffffffffffff0fffull) | 0x0000000000004000ull; - uuid.items[1] = (uuid.items[1] & 0x3fffffffffffffffull) | 0x8000000000000000ull; + /// https://tools.ietf.org/html/rfc4122#section-4.4 + + UInt128 & impl = uuid.toUnderType(); + impl.items[0] = (impl.items[0] & 0xffffffffffff0fffull) | 0x0000000000004000ull; + impl.items[1] = (impl.items[1] & 0x3fffffffffffffffull) | 0x8000000000000000ull; } return col_res;