Skip to content

[Feature] update_time datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP column is not support in case of dynamic partition table #63416

@tigerzhangyz

Description

@tigerzhangyz

Search before asking

  • I had searched in the issues and found no similar issues.

Description

CREATE TABLE test_on_update222 (
id bigint NULL,
value1 varchar(100) NULL,
value2 varchar(100) NULL,
create_time datetime NULL DEFAULT CURRENT_TIMESTAMP,
update_time datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=OLAP
UNIQUE KEY(id)
PARTITION BY RANGE (create_time)
(
PARTITION p_history VALUES LESS THAN ("2025-01-01"), -- 历史分区
FROM ("2025-01-01") TO ("2040-01-01") INTERVAL 3 MONTH, -- 自动生成2025-2040年的月份分区
PARTITION p_future VALUES [("2040-01-01"), (MAXVALUE)) -- 未来分区
)
DISTRIBUTED BY HASH(id) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"group_commit_interval_ms" = "10000", -- 默认10s
"group_commit_data_bytes" = "67108864", -- 默认64MB
-- "function_column.sequence_col" = '__sys_seq',
"enable_unique_key_merge_on_write" = "true"
); ERROR 1105 (HY000): errCode = 2, detailMessage = Syntax error in line 6:
...DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
^
Encountered: ON
Expected: COMMA

Use case

another BUG: DEFAULT CURRENT_TIMESTAMP is not triggered when new record is inserted, but replaced by the timestamp which is the value of table created. drop TABLE utils.test5;
CREATE TABLE utils.test5 (
fct_bid varchar(64) NULL COMMENT '事实BID,由业务主键经过特殊哈希处理得到',
user_sk bigint NOT NULL COMMENT '用户维度SK',
activity_time datetime NOT NULL COMMENT '活动时间',
__sys_seq datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '序列列',
__sys_ctime datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '中台入库时间',
__sys_utime datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '中台更新时间',
__sys_aid bigint NOT NULL AUTO_INCREMENT(1) COMMENT '中台自增ID'
) ENGINE=OLAP
UNIQUE KEY(fct_bid, user_sk, activity_time)
COMMENT 'AI开发活动事实表'
PARTITION BY RANGE (activity_time)
(
PARTITION p_history VALUES LESS THAN ("2025-01-01"), -- 历史分区
FROM ("2025-01-01") TO ("2040-01-01") INTERVAL 3 MONTH, -- 自动生成2025-2040年的月份分区
PARTITION p_future VALUES [("2040-01-01"), (MAXVALUE)) -- 未来分区
)
DISTRIBUTED BY HASH(user_sk) BUCKETS 18
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"group_commit_interval_ms" = "10000", -- 默认10s
"group_commit_data_bytes" = "67108864", -- 默认64MB
"function_column.sequence_col" = '__sys_seq',
"enable_unique_key_merge_on_write" = "true"
);

SET enable_unique_key_partial_update=true;
SET enable_insert_strict=false;
SET insert_max_filter_ratio=0;
truncate TABLE utils.test5;select sleep(3);
insert into utils.test5 (fct_bid,user_sk,activity_time) values(-9999999,9999999,now());
select * from utils.test5 \G
mysql> select * from utils.test5 ;
+----------+---------+---------------------+---------------------+---------------------+---------------------+-----------+
| fct_bid | user_sk | activity_time | __sys_seq | __sys_ctime | __sys_utime | __sys_aid |
+----------+---------+---------------------+---------------------+---------------------+---------------------+-----------+
| -9999999 | 9999999 | 2026-05-15 14:38:29 | 2026-05-15 14:38:05 | 2026-05-15 14:38:05 | 2026-05-15 14:38:05 | 1 |
+----------+---------+---------------------+---------------------+---------------------+---------------------+-----------+
1 row in set (0.01 sec)

Related issues

not yet

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions