starrocks icon indicating copy to clipboard operation
starrocks copied to clipboard

[Enhancement] Partial update support expr

Open sevev opened this issue 6 months ago • 4 comments

Why I'm doing:

Partial update does not support expression currently. If an expression column is not specified in the update, we will fill it with the default value instead of calculating it based on the expression.

What I'm doing:

Support partial update with expr e.g.

 CREATE TABLE `test` (
  `k1` bigint(20) NOT NULL COMMENT "",
  `v1` bigint(20) NOT NULL COMMENT "",
  `v2` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT ""
) ENGINE=OLAP
PRIMARY KEY(`k1`)
DISTRIBUTED BY HASH(`k1`) BUCKETS 1
PROPERTIES (
"compression" = "LZ4",
"enable_persistent_index" = "true",
"fast_schema_evolution" = "true",
"replicated_storage" = "true",
"replication_num" = "1"
);
insert into test values (1,1,'2024-08-27 00:00:00');
insert into test (k1,v1) values(2,2);
select * from test;

before this pr, the result is

mysql> select * from test;
+------+------+---------------------+
| k1   | v1   | v2                  |
+------+------+---------------------+
|    2 |    2 | NULL                |
|    1 |    1 | 2024-08-27 00:00:00 |
+------+------+---------------------+
2 rows in set (0.02 sec)

after this pr:

mysql> select * from test;
+------+------+---------------------+
| k1   | v1   | v2                  |
+------+------+---------------------+
|    1 |    1 | 2024-08-27 00:00:00 |
|    2 |    2 | 2024-08-27 19:02:23 |
+------+------+---------------------+
2 rows in set (0.01 sec)

Fixes #issue

What type of PR is this:

  • [ ] BugFix
  • [ ] Feature
  • [x] Enhancement
  • [ ] Refactor
  • [ ] UT
  • [ ] Doc
  • [ ] Tool

Does this PR entail a change in behavior?

  • [ ] Yes, this PR will result in a change in behavior.
  • [x] No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • [ ] Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • [ ] Parameter changes: default values, similar parameters but with different default values
  • [ ] Policy changes: use new policy to replace old one, functionality automatically enabled
  • [ ] Feature removed
  • [ ] Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • [x] I have added test cases for my bug fix or my new feature
  • [ ] This pr needs user documentation (for new or modified features or behaviors)
    • [ ] I have added documentation for my new feature or new function
  • [ ] This is a backport pr

Bugfix cherry-pick branch check:

  • [x] I have checked the version labels which the pr will be auto-backported to the target branch
    • [x] 3.3
    • [x] 3.2
    • [ ] 3.1
    • [ ] 3.0
    • [ ] 2.5

sevev avatar Aug 27 '24 02:08 sevev