<vscluster>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>node1</host>
</replica>
<replica>
<host>node2</host>
</replica>
</shard>
</vscluster><macros>
<shard>s1</shard>
<replica>node1</replica>
</macros><macros>
<shard>s1</shard>
<replica>node2</replica>
</macros>CREATE DATABASE vs ON CLUSTER vscluster
CREATE TABLE IF NOT EXISTS vs.t1 ON CLUSTER vscluster (ts DATETIME,c1 VARCHAR) ENGINE=ReplicatedMergeTree('/clickhouse/tables/{shard}/t1','{replica}') PARTITION BY toStartOfYear(ts) ORDER BY tuple()
CREATE TABLE IF NOT EXISTS vs.t1_distrib ON CLUSTER vscluster (ts DATETIME,c1 VARCHAR) ENGINE=Distributed('vscluster','vs','t1')
ALTER TABLE vs.t1 ON CLUSTER vscluster ADD COLUMN c2 VARCHAR
ALTER TABLE vs.t1_distrib ON CLUSTER vscluster ADD COLUMN c2 VARCHAR
=> error
Code: 371, e.displayText() = DB::Exception: Table t1_distrib isn't replicated, but shard #1 is replicated according to its cluster definition, e.what() = DB::Exception.Connected to ClickHouse server version 18.12.17 revision 54407.
Technically it's a bug, because create and alter have different behavior.
internal_replication = true, so CH tries to execute alter only on the first replica but t1_distrib is not replicated, and you get this error.
When you execute "ALTER TABLE vs.t1 ON CLUSTER vscluster" CH checks that internal_replication = true and sends alter to only one replica and other replica performs this alter using table (replicated) engine.
Workarounds
1. drop / create distrib table each time, BTW you can use sharded table as columns definition
CREATE TABLE IF NOT EXISTS vs.t1_distrib ON CLUSTER vscluster as vs.t1 ENGINE=Distributed('vscluster','vs','t1')
<vscluster_all>
<shard>
<replica>
<host>node1</host>
</replica> </shard> <shard>
<replica>
<host>node2</host>
</replica>
</shard>
</vscluster>ALTER TABLE vs.t1_distrib ON CLUSTER vscluster_all ADD COLUMN c2 VARCHAR