mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #21728 from ClickHouse/fix_alter_decimal
Fix alter modify for decimal columns when type size doesn't change
This commit is contained in:
commit
848bb59175
@ -907,7 +907,6 @@ void StorageReplicatedMergeTree::setTableStructure(
|
||||
StorageInMemoryMetadata new_metadata = getInMemoryMetadata();
|
||||
StorageInMemoryMetadata old_metadata = getInMemoryMetadata();
|
||||
|
||||
if (new_columns != new_metadata.columns)
|
||||
new_metadata.columns = new_columns;
|
||||
|
||||
if (!metadata_diff.empty())
|
||||
@ -976,8 +975,6 @@ void StorageReplicatedMergeTree::setTableStructure(
|
||||
}
|
||||
|
||||
/// Changes in columns may affect following metadata fields
|
||||
if (new_metadata.columns != old_metadata.columns)
|
||||
{
|
||||
new_metadata.column_ttls_by_name.clear();
|
||||
for (const auto & [name, ast] : new_metadata.columns.getColumnTTLs())
|
||||
{
|
||||
@ -1014,7 +1011,6 @@ void StorageReplicatedMergeTree::setTableStructure(
|
||||
if (!metadata_diff.ttl_table_changed && new_metadata.table_ttl.definition_ast != nullptr)
|
||||
new_metadata.table_ttl = TTLTableDescription::getTTLForTableFromAST(
|
||||
new_metadata.table_ttl.definition_ast, new_metadata.columns, global_context, new_metadata.primary_key);
|
||||
}
|
||||
|
||||
/// Even if the primary/sorting/partition keys didn't change we must reinitialize it
|
||||
/// because primary/partition key column types might have changed.
|
||||
|
@ -0,0 +1,9 @@
|
||||
1 5.00000000
|
||||
2 6.00000000
|
||||
CREATE TABLE default.test_alter_decimal\n(\n `n` UInt64,\n `d` Decimal(18, 8)\n)\nENGINE = ReplicatedMergeTree(\'/clickhouse/01761_alter_decimal_zookeeper\', \'r1\')\nORDER BY tuple()\nSETTINGS index_granularity = 8192
|
||||
1 5.00000000
|
||||
2 6.00000000
|
||||
CREATE TABLE default.test_alter_decimal\n(\n `n` UInt64,\n `d` Decimal(18, 8)\n)\nENGINE = ReplicatedMergeTree(\'/clickhouse/01761_alter_decimal_zookeeper\', \'r1\')\nORDER BY tuple()\nSETTINGS index_granularity = 8192
|
||||
1 5.00000000
|
||||
2 6.00000000
|
||||
3 7.00000000
|
31
tests/queries/0_stateless/01761_alter_decimal_zookeeper.sql
Normal file
31
tests/queries/0_stateless/01761_alter_decimal_zookeeper.sql
Normal file
@ -0,0 +1,31 @@
|
||||
DROP TABLE IF EXISTS test_alter_decimal;
|
||||
|
||||
CREATE TABLE test_alter_decimal
|
||||
(n UInt64, d Decimal(15, 8))
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/01761_alter_decimal_zookeeper', 'r1')
|
||||
ORDER BY tuple();
|
||||
|
||||
INSERT INTO test_alter_decimal VALUES (1, toDecimal32(5, 5));
|
||||
|
||||
INSERT INTO test_alter_decimal VALUES (2, toDecimal32(6, 6));
|
||||
|
||||
SELECT * FROM test_alter_decimal ORDER BY n;
|
||||
|
||||
ALTER TABLE test_alter_decimal MODIFY COLUMN d Decimal(18, 8);
|
||||
|
||||
SHOW CREATE TABLE test_alter_decimal;
|
||||
|
||||
SELECT * FROM test_alter_decimal ORDER BY n;
|
||||
|
||||
DETACH TABLE test_alter_decimal;
|
||||
ATTACH TABLE test_alter_decimal;
|
||||
|
||||
SHOW CREATE TABLE test_alter_decimal;
|
||||
|
||||
INSERT INTO test_alter_decimal VALUES (3, toDecimal32(7, 7));
|
||||
|
||||
OPTIMIZE TABLE test_alter_decimal FINAL;
|
||||
|
||||
SELECT * FROM test_alter_decimal ORDER BY n;
|
||||
|
||||
DROP TABLE IF EXISTS test_alter_decimal;
|
@ -111,6 +111,7 @@
|
||||
"memory_tracking",
|
||||
"memory_usage",
|
||||
"live_view",
|
||||
"01761_alter_decimal_zookeeper",
|
||||
"01560_optimize_on_insert_zookeeper",
|
||||
"01720_type_map_and_casts",
|
||||
"01413_alter_update_supertype",
|
||||
@ -755,6 +756,7 @@
|
||||
"01700_system_zookeeper_path_in",
|
||||
"01715_background_checker_blather_zookeeper",
|
||||
"01747_alter_partition_key_enum_zookeeper",
|
||||
"01761_alter_decimal_zookeeper",
|
||||
"attach",
|
||||
"ddl_dictionaries",
|
||||
"dictionary",
|
||||
|
Loading…
Reference in New Issue
Block a user