mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
don't quote single-field partition keys #3109 [#CLICKHOUSE-4054]
This commit is contained in:
parent
34bd8568b6
commit
d9a0432c6c
@ -2184,7 +2184,7 @@ String MergeTreeData::getPartitionIDFromQuery(const ASTPtr & ast, const Context
|
||||
{
|
||||
WriteBufferFromOwnString buf;
|
||||
writeCString("Parsed partition value: ", buf);
|
||||
partition.serializeTextQuoted(*this, buf, format_settings);
|
||||
partition.serializeText(*this, buf, format_settings);
|
||||
writeCString(" doesn't match partition value for an existing part with the same partition ID: ", buf);
|
||||
writeString(existing_part_in_partition->name, buf);
|
||||
throw Exception(buf.str(), ErrorCodes::INVALID_PARTITION_VALUE);
|
||||
|
@ -77,32 +77,36 @@ String MergeTreePartition::getID(const MergeTreeData & storage) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void MergeTreePartition::serializeTextQuoted(const MergeTreeData & storage, WriteBuffer & out, const FormatSettings & format_settings) const
|
||||
void MergeTreePartition::serializeText(const MergeTreeData & storage, WriteBuffer & out, const FormatSettings & format_settings) const
|
||||
{
|
||||
size_t key_size = storage.partition_key_sample.columns();
|
||||
|
||||
if (key_size == 0)
|
||||
{
|
||||
writeCString("tuple()", out);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key_size > 1)
|
||||
writeChar('(', out);
|
||||
|
||||
for (size_t i = 0; i < key_size; ++i)
|
||||
else if (key_size == 1)
|
||||
{
|
||||
if (i > 0)
|
||||
writeCString(", ", out);
|
||||
|
||||
const DataTypePtr & type = storage.partition_key_sample.getByPosition(i).type;
|
||||
const DataTypePtr & type = storage.partition_key_sample.getByPosition(0).type;
|
||||
auto column = type->createColumn();
|
||||
column->insert(value[i]);
|
||||
type->serializeTextQuoted(*column, 0, out, format_settings);
|
||||
column->insert(value[0]);
|
||||
type->serializeText(*column, 0, out, format_settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeChar('(', out);
|
||||
for (size_t i = 0; i < key_size; ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
writeCString(", ", out);
|
||||
|
||||
if (key_size > 1)
|
||||
const DataTypePtr & type = storage.partition_key_sample.getByPosition(i).type;
|
||||
auto column = type->createColumn();
|
||||
column->insert(value[i]);
|
||||
type->serializeTextQuoted(*column, 0, out, format_settings);
|
||||
}
|
||||
writeChar(')', out);
|
||||
}
|
||||
}
|
||||
|
||||
void MergeTreePartition::load(const MergeTreeData & storage, const String & part_path)
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
|
||||
String getID(const MergeTreeData & storage) const;
|
||||
|
||||
void serializeTextQuoted(const MergeTreeData & storage, WriteBuffer & out, const FormatSettings & format_settings) const;
|
||||
void serializeText(const MergeTreeData & storage, WriteBuffer & out, const FormatSettings & format_settings) const;
|
||||
|
||||
void load(const MergeTreeData & storage, const String & part_path);
|
||||
void store(const MergeTreeData & storage, const String & part_path, MergeTreeDataPartChecksums & checksums) const;
|
||||
|
@ -61,7 +61,7 @@ void StorageSystemParts::processNextStorage(MutableColumns & columns, const Stor
|
||||
size_t i = 0;
|
||||
{
|
||||
WriteBufferFromOwnString out;
|
||||
part->partition.serializeTextQuoted(*info.data, out, format_settings);
|
||||
part->partition.serializeText(*info.data, out, format_settings);
|
||||
columns[i++]->insert(out.str());
|
||||
}
|
||||
columns[i++]->insert(part->name);
|
||||
|
@ -106,7 +106,7 @@ void StorageSystemPartsColumns::processNextStorage(MutableColumns & columns, con
|
||||
size_t j = 0;
|
||||
{
|
||||
WriteBufferFromOwnString out;
|
||||
part->partition.serializeTextQuoted(*info.data, out, format_settings);
|
||||
part->partition.serializeText(*info.data, out, format_settings);
|
||||
columns[j++]->insert(out.str());
|
||||
}
|
||||
columns[j++]->insert(part->name);
|
||||
|
@ -10,12 +10,12 @@ Sum after DETACH PARTITION:
|
||||
0
|
||||
*** Partitioned by week ***
|
||||
Parts before OPTIMIZE:
|
||||
\'1999-12-27\' 19991227_1_1_0
|
||||
\'2000-01-03\' 20000103_2_2_0
|
||||
\'2000-01-03\' 20000103_3_3_0
|
||||
1999-12-27 19991227_1_1_0
|
||||
2000-01-03 20000103_2_2_0
|
||||
2000-01-03 20000103_3_3_0
|
||||
Parts after OPTIMIZE:
|
||||
\'1999-12-27\' 19991227_1_1_0
|
||||
\'2000-01-03\' 20000103_2_3_1
|
||||
1999-12-27 19991227_1_1_0
|
||||
2000-01-03 20000103_2_3_1
|
||||
Sum before DROP PARTITION:
|
||||
15
|
||||
Sum after DROP PARTITION:
|
||||
@ -37,14 +37,14 @@ Sum after DETACH PARTITION:
|
||||
9
|
||||
*** Partitioned by String ***
|
||||
Parts before OPTIMIZE:
|
||||
\'bbb\' 7d878f3d88441d2b3dc371e2a3050f6d_2_2_0
|
||||
\'bbb\' 7d878f3d88441d2b3dc371e2a3050f6d_3_3_0
|
||||
\'aaa\' 9b50856126a8a6064f11f027d455bf58_1_1_0
|
||||
\'aaa\' 9b50856126a8a6064f11f027d455bf58_4_4_0
|
||||
bbb 7d878f3d88441d2b3dc371e2a3050f6d_2_2_0
|
||||
bbb 7d878f3d88441d2b3dc371e2a3050f6d_3_3_0
|
||||
aaa 9b50856126a8a6064f11f027d455bf58_1_1_0
|
||||
aaa 9b50856126a8a6064f11f027d455bf58_4_4_0
|
||||
Parts after OPTIMIZE:
|
||||
\'bbb\' 7d878f3d88441d2b3dc371e2a3050f6d_2_2_0
|
||||
\'bbb\' 7d878f3d88441d2b3dc371e2a3050f6d_3_3_0
|
||||
\'aaa\' 9b50856126a8a6064f11f027d455bf58_1_4_1
|
||||
bbb 7d878f3d88441d2b3dc371e2a3050f6d_2_2_0
|
||||
bbb 7d878f3d88441d2b3dc371e2a3050f6d_3_3_0
|
||||
aaa 9b50856126a8a6064f11f027d455bf58_1_4_1
|
||||
Sum before DROP PARTITION:
|
||||
15
|
||||
Sum after DROP PARTITION:
|
||||
|
@ -10,12 +10,12 @@ Sum after DETACH PARTITION:
|
||||
0
|
||||
*** Partitioned by week ***
|
||||
Parts before OPTIMIZE:
|
||||
\'1999-12-27\' 19991227_0_0_0
|
||||
\'2000-01-03\' 20000103_0_0_0
|
||||
\'2000-01-03\' 20000103_1_1_0
|
||||
1999-12-27 19991227_0_0_0
|
||||
2000-01-03 20000103_0_0_0
|
||||
2000-01-03 20000103_1_1_0
|
||||
Parts after OPTIMIZE:
|
||||
\'1999-12-27\' 19991227_0_0_0
|
||||
\'2000-01-03\' 20000103_0_1_1
|
||||
1999-12-27 19991227_0_0_0
|
||||
2000-01-03 20000103_0_1_1
|
||||
Sum before DROP PARTITION:
|
||||
15
|
||||
Sum after DROP PARTITION:
|
||||
@ -37,14 +37,14 @@ Sum after DETACH PARTITION:
|
||||
9
|
||||
*** Partitioned by String ***
|
||||
Parts before OPTIMIZE:
|
||||
\'bbb\' 7d878f3d88441d2b3dc371e2a3050f6d_0_0_0
|
||||
\'bbb\' 7d878f3d88441d2b3dc371e2a3050f6d_1_1_0
|
||||
\'aaa\' 9b50856126a8a6064f11f027d455bf58_0_0_0
|
||||
\'aaa\' 9b50856126a8a6064f11f027d455bf58_1_1_0
|
||||
bbb 7d878f3d88441d2b3dc371e2a3050f6d_0_0_0
|
||||
bbb 7d878f3d88441d2b3dc371e2a3050f6d_1_1_0
|
||||
aaa 9b50856126a8a6064f11f027d455bf58_0_0_0
|
||||
aaa 9b50856126a8a6064f11f027d455bf58_1_1_0
|
||||
Parts after OPTIMIZE:
|
||||
\'bbb\' 7d878f3d88441d2b3dc371e2a3050f6d_0_0_0
|
||||
\'bbb\' 7d878f3d88441d2b3dc371e2a3050f6d_1_1_0
|
||||
\'aaa\' 9b50856126a8a6064f11f027d455bf58_0_1_1
|
||||
bbb 7d878f3d88441d2b3dc371e2a3050f6d_0_0_0
|
||||
bbb 7d878f3d88441d2b3dc371e2a3050f6d_1_1_0
|
||||
aaa 9b50856126a8a6064f11f027d455bf58_0_1_1
|
||||
Sum before DROP PARTITION:
|
||||
15
|
||||
Sum after DROP PARTITION:
|
||||
|
Loading…
Reference in New Issue
Block a user