v2.1.5
建表语句:
CREATE TABLE `bug` (
`ts` BIGINT NULL,
`metric` BIGINT NULL,
`date` INT NOT NULL,
`hour` INT NOT NULL
) ENGINE=OLAP
DUPLICATE KEY(`ts`)
COMMENT 'OLAP'
PARTITION BY LIST(`date`, `hour`)
(PARTITION p202409095 VALUES IN (("20240909", "5")))
DISTRIBUTED BY RANDOM BUCKETS 1
测试写入正常
mysql> insert into bug values(123,8888,20240909,5);
Query OK, 1 row affected (0.14 sec)
{'label':'group_commit_a84a05cf59f7eac5_2717ca5878ab22b6', 'status':'PREPARE', 'txnId':'6615640', 'query_id':'3bb54de0b1424539-8ba9b3ddae96112f'}
建立物化视图
CREATE MATERIALIZED VIEW bug_mv AS
select date,hour,ts,sum(metric)
from bug
where metric > 0
group by date,hour,ts;
等待物化视图建立成功后,增加列
ALTER TABLE `bug` ADD COLUMN `sdk_ec` VARCHAR(255) NULL;
等待light schema change成功后,测试写入 失败
mysql> insert into bug values(123,8888,20240909,5,"213");
ERROR 1052 (23000): errCode = 2, detailMessage = Column 'metric' in field list is ambiguous
经测试 需要删除mv后 才能正常写入
而如果mv ddl里没有使用 where metric > 0,新增列之后 则不会出现上述写入失败的情况