mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Support for big integers and decimals in GenerateRandom
This commit is contained in:
parent
089027920f
commit
db3baabae7
@ -213,10 +213,7 @@ ColumnPtr fillColumnWithRandomData(
|
||||
{
|
||||
auto column = ColumnUInt16::create();
|
||||
column->getData().resize(limit);
|
||||
|
||||
for (size_t i = 0; i < limit; ++i)
|
||||
column->getData()[i] = rng() % (DATE_LUT_MAX_DAY_NUM + 1);
|
||||
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column->getData().data()), limit * sizeof(UInt16), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::UInt32: [[fallthrough]];
|
||||
@ -234,14 +231,28 @@ ColumnPtr fillColumnWithRandomData(
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column->getData().data()), limit * sizeof(UInt64), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::UInt128: [[fallthrough]];
|
||||
case TypeIndex::UUID:
|
||||
case TypeIndex::UInt128:
|
||||
{
|
||||
auto column = ColumnUInt128::create();
|
||||
column->getData().resize(limit);
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column->getData().data()), limit * sizeof(UInt128), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::UInt256:
|
||||
{
|
||||
auto column = ColumnUInt256::create();
|
||||
column->getData().resize(limit);
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column->getData().data()), limit * sizeof(UInt256), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::UUID:
|
||||
{
|
||||
auto column = ColumnUUID::create();
|
||||
column->getData().resize(limit);
|
||||
/// NOTE This is slightly incorrect as random UUIDs should have fixed version 4.
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column->getData().data()), limit * sizeof(UUID), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::Int8:
|
||||
{
|
||||
auto column = ColumnInt8::create();
|
||||
@ -270,6 +281,20 @@ ColumnPtr fillColumnWithRandomData(
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column->getData().data()), limit * sizeof(Int64), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::Int128:
|
||||
{
|
||||
auto column = ColumnInt128::create();
|
||||
column->getData().resize(limit);
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column->getData().data()), limit * sizeof(Int128), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::Int256:
|
||||
{
|
||||
auto column = ColumnInt256::create();
|
||||
column->getData().resize(limit);
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column->getData().data()), limit * sizeof(Int256), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::Float32:
|
||||
{
|
||||
auto column = ColumnFloat32::create();
|
||||
@ -308,6 +333,14 @@ ColumnPtr fillColumnWithRandomData(
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column_concrete.getData().data()), limit * sizeof(Decimal128), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::Decimal256:
|
||||
{
|
||||
auto column = type->createColumn();
|
||||
auto & column_concrete = typeid_cast<ColumnDecimal<Decimal256> &>(*column);
|
||||
column_concrete.getData().resize(limit);
|
||||
fillBufferWithRandomData(reinterpret_cast<char *>(column_concrete.getData().data()), limit * sizeof(Decimal256), rng);
|
||||
return column;
|
||||
}
|
||||
case TypeIndex::FixedString:
|
||||
{
|
||||
size_t n = typeid_cast<const DataTypeFixedString &>(*type).getN();
|
||||
|
Loading…
Reference in New Issue
Block a user