Agg模型value列(REPLACE_IF_NOT_NULL)指定默认值问题

Viewed 26

版本:2.0.12

建表语句

CREATE TABLE `xxx` (
  `pt` date,
  `ed_code` VARCHAR(30),
  `order_id` BIGINT,
  `idea_id` BIGINT,
  `year` VARCHAR(10),
  `month` VARCHAR(10),
  `use_area` TINYINT,
  `order_source` VARCHAR(50),
  `point_id` BITMAP BITMAP_UNION,
  `play_dur` BIGINT SUM DEFAULT "0",
  `play_cnt` BIGINT SUM DEFAULT "0",
  `click_cnt` BIGINT SUM DEFAULT "0",
  `history_publish_flag` TINYINT REPLACE_IF_NOT_NULL DEFAULT "1",
  `publish_flag` TINYINT REPLACE_IF_NOT_NULL DEFAULT "0"
) AGGREGATE KEY(
  `pt`,
  `ed_code`,
  `order_id`,
  `idea_id`,
  `year`,
  `month`,
  `use_area`,
  `order_source`
)

Agg模型value列(publish_flag)默认值0,首先修改publish_flag为1,如果部分列更新不指定publish_flag字段,那么该字段会被更新成默认值0,结果不符合预期(REPLACE_IF_NOT_NULL)

publish_flag字段修改为1

insert into xxx(pt,ed_code,order_id,idea_id,year,month,use_area,order_source,point_id,publish_flag) values('2024-11-05', '66666666', '3333333', '4444444', '2024', '2024-11', '2', 'order', to_bitmap(1),1);

image.png

更新其它列,publish_flag值被修改为默认值0

insert into xxx(pt,ed_code,order_id,idea_id,year,month,use_area,order_source,point_id,play_dur,play_cnt,click_cnt) values('2024-11-05', '66666666', '3333333', '4444444', '2024', '2024-11', '2', 'order',to_bitmap(1), 6, 1, 0);

image.png

1 Answers

agg表做部分列更新的要求是聚合函数为REPLACE_IF_NOT_NULL,默认值为NULL才行。