bobhan1 opened a new pull request, #40272:
URL: https://github.com/apache/doris/pull/40272

   ## Proposed changes
   
   ### 1. Fix `__DORIS_SEQUENCE_COL__` is not set for newly inserted rows in 
partial update
   before:
   ```sql
   MySQL root@127.1:d1> CREATE TABLE IF NOT EXISTS t3 (
                     ->   `k` BIGINT NOT NULL,
                     ->   `c1` int,
                     ->   `c2` datetime default current_timestamp,
                     ->  ) UNIQUE KEY(`k`)
                     ->  DISTRIBUTED BY HASH(`k`) BUCKETS 1
                     ->  PROPERTIES (
                     ->  "replication_allocation" = "tag.location.default: 1",
                     ->  "enable_unique_key_merge_on_write" = "true",
                     ->  "function_column.sequence_col" = "c2"
                     ->  );
   Query OK, 0 rows affected
   MySQL root@127.1:d1> set enable_insert_strict=false;
   MySQL root@127.1:d1> set enable_unique_key_partial_update=true;
   MySQL root@127.1:d1> insert into t3(k,c1) values(99,99);
   MySQL root@127.1:d1> set show_hidden_columns=true;
   MySQL root@127.1:d1> select * from t3;
   
+----+----+---------------------+-----------------------+-----------------------+------------------------+
   | k  | c1 | c2                  | __DORIS_DELETE_SIGN__ | 
__DORIS_VERSION_COL__ | __DORIS_SEQUENCE_COL__ |
   
+----+----+---------------------+-----------------------+-----------------------+------------------------+
   | 99 | 99 | 2024-09-02 11:03:09 | 0                     | 2                  
   | <null>                 |
   
+----+----+---------------------+-----------------------+-----------------------+------------------------+
   ```
   after:
   ```sql
   MySQL root@127.1:d1> CREATE TABLE IF NOT EXISTS t3 (
                     ->   `k` BIGINT NOT NULL,
                     ->   `c1` int,
                     ->   `c2` datetime default current_timestamp,
                     ->  ) UNIQUE KEY(`k`)
                     ->  DISTRIBUTED BY HASH(`k`) BUCKETS 1
                     ->  PROPERTIES (
                     ->  "replication_allocation" = "tag.location.default: 1",
                     ->  "enable_unique_key_merge_on_write" = "true",
                     ->  "function_column.sequence_col" = "c2"
                     ->  );
   Query OK, 0 rows affected
   MySQL root@127.1:d1> set enable_insert_strict=false;
   MySQL root@127.1:d1> set enable_unique_key_partial_update=true;
   MySQL root@127.1:d1> insert into t3(k,c1) values(1,10);
   MySQL root@127.1:d1> set show_hidden_columns=true;
   MySQL root@127.1:d1> select * from t3;
   
+---+----+---------------------+-----------------------+-----------------------+------------------------+
   | k | c1 | c2                  | __DORIS_DELETE_SIGN__ | 
__DORIS_VERSION_COL__ | __DORIS_SEQUENCE_COL__ |
   
+---+----+---------------------+-----------------------+-----------------------+------------------------+
   | 1 | 10 | 2024-09-02 16:49:50 | 0                     | 2                   
  | 2024-09-02 16:49:50    |
   
+---+----+---------------------+-----------------------+-----------------------+------------------------+
   ```
   ### 2. Fix `current_timestamp()` precision loss for newly inserted rows in 
partial update
   before:
   ```sql
   MySQL root@127.1:d1> CREATE TABLE IF NOT EXISTS t3 (
                     ->   `k` BIGINT NOT NULL,
                     ->   `c1` int,
                     ->   `c2` datetime(6) default current_timestamp(6),
                     ->  ) UNIQUE KEY(`k`)
                     ->  DISTRIBUTED BY HASH(`k`) BUCKETS 1
                     ->  PROPERTIES (
                     ->  "replication_allocation" = "tag.location.default: 1",
                     ->  "enable_unique_key_merge_on_write" = "true",
                     ->  "function_column.sequence_col" = "c2"
                     ->  );
   Query OK, 0 rows affected
   MySQL root@127.1:d1> set enable_unique_key_partial_update=true;
   MySQL root@127.1:d1> set enable_insert_strict=false;
   MySQL root@127.1:d1> insert into t3(k,c1) values(3,10);
   MySQL root@127.1:d1> set show_hidden_columns=true;
   MySQL root@127.1:d1> select * from t3;
   
+---+----+----------------------------+-----------------------+-----------------------+----------------------------+
   | k | c1 | c2                         | __DORIS_DELETE_SIGN__ | 
__DORIS_VERSION_COL__ | __DORIS_SEQUENCE_COL__     |
   
+---+----+----------------------------+-----------------------+-----------------------+----------------------------+
   | 3 | 10 | 2024-09-02 19:04:55        | 0                     | 2            
         | 2024-09-02 19:04:55        |
   
+---+----+----------------------------+-----------------------+-----------------------+----------------------------+
   ```
   after:
   ```sql
   MySQL root@127.1:d1> CREATE TABLE IF NOT EXISTS t3 (
                     ->   `k` BIGINT NOT NULL,
                     ->   `c1` int,
                     ->   `c2` datetime(6) default current_timestamp(6),
                     ->  ) UNIQUE KEY(`k`)
                     ->  DISTRIBUTED BY HASH(`k`) BUCKETS 1
                     ->  PROPERTIES (
                     ->  "replication_allocation" = "tag.location.default: 1",
                     ->  "enable_unique_key_merge_on_write" = "true",
                     ->  "function_column.sequence_col" = "c2"
                     ->  );
   Query OK, 0 rows affected
   MySQL root@127.1:d1> set enable_unique_key_partial_update=true;
   MySQL root@127.1:d1> set enable_insert_strict=false;
   MySQL root@127.1:d1> insert into t3(k,c1) values(3,10);
   MySQL root@127.1:d1> set show_hidden_columns=true;
   MySQL root@127.1:d1> select * from t3;
   
+---+----+----------------------------+-----------------------+-----------------------+----------------------------+
   | k | c1 | c2                         | __DORIS_DELETE_SIGN__ | 
__DORIS_VERSION_COL__ | __DORIS_SEQUENCE_COL__     |
   
+---+----+----------------------------+-----------------------+-----------------------+----------------------------+
   | 3 | 10 | 2024-09-02 19:04:55.464438 | 0                     | 2            
         | 2024-09-02 19:04:55.464438 |
   
+---+----+----------------------------+-----------------------+-----------------------+----------------------------+
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to