Skip to content

Inconsistent ALTER behaviour. #8669

@alesapin

Description

@alesapin

Describe the bug or unexpected behavior
Modification of type of column with non-materialized defaults leads to wrong default values.

How to reproduce

CREATE TABLE test_alter_on_mutation
(
  date Date,
  key UInt64
)
ENGINE ReplicatedMergeTree('/clickhouse/tables/test_alter_on_mutation', '1')
ORDER BY key;

INSERT INTO test_alter_on_mutation select toDate('2020-01-05'), number from system.numbers limit 100;

ALTER TABLE test_alter_on_mutation ADD COLUMN value String DEFAULT '10';

SELECT sum(cast(value as UInt64)) from test_alter_on_mutation;

┌─sum(CAST(value, 'UInt64'))─┐
│                       1000 │
└────────────────────────────┘

-- OPTIMIZE TABLE test_alter_on_mutation FINAL;

ALTER TABLE test_alter_on_mutation MODIFY COLUMN value UInt64;

SELECT sum(value) from test_alter_on_mutation;

┌─sum(value)─┐
│          0 │
└────────────┘

Metadata

Metadata

Assignees

Labels

bugConfirmed user-visible misbehaviour in official release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions