diff --git a/be/src/olap/base_tablet.cpp b/be/src/olap/base_tablet.cpp index 8b2e566b9b13ce..b4ab6a167e6f5f 100644 --- a/be/src/olap/base_tablet.cpp +++ b/be/src/olap/base_tablet.cpp @@ -1059,7 +1059,7 @@ Status BaseTablet::generate_new_block_for_partial_update( mutable_column.get()) ->insert_default(); } else { - mutable_column->insert_default(); + mutable_column->insert(rs_column.get_vec_type()->get_default()); } } else { mutable_column->insert_from(*old_block.get_by_position(i).column, @@ -1173,7 +1173,7 @@ Status BaseTablet::generate_new_block_for_flexible_partial_update( new_col.get()) ->insert_default(); } else { - new_col->insert_default(); + new_col->insert(tablet_column.get_vec_type()->get_default()); } } else { new_col->insert_from(old_value_col, idx); diff --git a/be/src/olap/partial_update_info.cpp b/be/src/olap/partial_update_info.cpp index 1ca269a0f317b7..e9a7f571ff3a9e 100644 --- a/be/src/olap/partial_update_info.cpp +++ b/be/src/olap/partial_update_info.cpp @@ -406,7 +406,7 @@ Status FixedReadPlan::fill_missing_columns( // If the control flow reaches this branch, the column neither has default value // nor is nullable. It means that the row's delete sign is marked, and the value // columns are useless and won't be read. So we can just put arbitary values in the cells - missing_col->insert_default(); + missing_col->insert(tablet_column.get_vec_type()->get_default()); } // clang-format on } @@ -579,7 +579,7 @@ Status FlexibleReadPlan::fill_non_primary_key_columns_for_column_store( new_col.get()) ->insert_default(); } else { - new_col->insert_default(); + new_col->insert(tablet_column.get_vec_type()->get_default()); } } else { auto pos_in_old_block = read_index.at(cid).at(segment_pos); @@ -653,7 +653,7 @@ Status FlexibleReadPlan::fill_non_primary_key_columns_for_row_store( new_col.get()) ->insert_default(); } else { - new_col->insert_default(); + new_col->insert(tablet_column.get_vec_type()->get_default()); } } else { new_col->insert_from(old_value_col, pos_in_old_block); diff --git a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_complex_type.out b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_complex_type.out index ae7ed3b79b904f..6f6a385a359772 100644 --- a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_complex_type.out +++ b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_complex_type.out @@ -21,6 +21,16 @@ 4 \N \N [1, 2, 3, 4, 5] \N 6 \N \N [] {"a":1000000, "b":10000000} +-- !sql -- +3 doris3 {"jsonk3":456,"jsonk5":789} [600, 400] {"a":2, "b":7} {"cccc":10} 4 0 + +-- !sql -- +1 doris1 {"jsonk1":123,"jsonk2":456} [100, 200] {"a":1, "b":2} {"b":3} 3 0 +1 \N null [null] {"a":null, "b":null} {null:null} 5 1 +2 doris2 {"jsonk2":333,"jsonk4":444} [300, 400] {"a":3, "b":4} {"a":2} 2 0 +2 \N null [null] {"a":null, "b":null} {null:null} 5 1 +3 doris3 {"jsonk3":456,"jsonk5":789} [600, 400] {"a":2, "b":7} {"cccc":10} 4 0 + -- !update_varchar -- 1 apache doris {"jsonk1":123,"jsonk2":456} [100, 200] {"a":1, "b":2} 2 apache doris 2.0 {"jsonk3":333,"jsonk4":444} [300, 400] {"a":3, "b":4} @@ -43,3 +53,13 @@ 4 \N \N [1, 2, 3, 4, 5] \N 6 \N \N [] {"a":1000000, "b":10000000} +-- !sql -- +3 doris3 {"jsonk3":456,"jsonk5":789} [600, 400] {"a":2, "b":7} {"cccc":10} 4 0 + +-- !sql -- +1 doris1 {"jsonk1":123,"jsonk2":456} [100, 200] {"a":1, "b":2} {"b":3} 3 0 +1 \N null [null] {"a":null, "b":null} {null:null} 5 1 +2 doris2 {"jsonk2":333,"jsonk4":444} [300, 400] {"a":3, "b":4} {"a":2} 2 0 +2 \N null [null] {"a":null, "b":null} {null:null} 5 1 +3 doris3 {"jsonk3":456,"jsonk5":789} [600, 400] {"a":2, "b":7} {"cccc":10} 4 0 + diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_complex_type.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_complex_type.groovy index ebd32310fd2b45..fc3cb097080e8c 100644 --- a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_complex_type.groovy +++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_complex_type.groovy @@ -1,4 +1,3 @@ - // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information @@ -32,7 +31,7 @@ suite("test_primary_key_partial_update_complex_type", "p0") { // 2. the combination of map type and row store may result in bugs, so we skip map type in temporary // // create table - sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ DROP TABLE IF EXISTS ${tableName} FORCE""" sql """ CREATE TABLE ${tableName} ( `id` int(11) NOT NULL COMMENT "用户 ID", `c_varchar` varchar(65533) NULL COMMENT "用户姓名", @@ -120,8 +119,36 @@ suite("test_primary_key_partial_update_complex_type", "p0") { select * from ${tableName} order by id; """ - // drop table - sql """ DROP TABLE IF EXISTS ${tableName} """ + // create table for NOT NULL tests + def tableName2 = "${tableName}_not_null" + sql """ DROP TABLE IF EXISTS ${tableName2} FORCE""" + sql """ CREATE TABLE ${tableName2} ( + `id` int(11) NOT NULL COMMENT "用户 ID", + `c_varchar` varchar(65533) NULL COMMENT "用户姓名", + `c_jsonb` JSONB NOT NULL, + `c_array` ARRAY NOT NULL, + `c_struct` STRUCT NOT NULL, + `c_map` MAP not null) + UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 1 + PROPERTIES("replication_num" = "1", "enable_unique_key_merge_on_write" = "true", + "store_row_column" = "${use_row_store}"); """ + + sql """insert into ${tableName2} values(2, "doris2", '{"jsonk2": 333, "jsonk4": 444}', [300, 400], {3, 4}, {'a': 2})""" + sql """insert into ${tableName2} values(1, "doris1", '{"jsonk1": 123, "jsonk2": 456}', [100, 200], {1, 2}, {'b': 3})""" + sql """insert into ${tableName2} values(3, "doris3", '{"jsonk3": 456, "jsonk5": 789}', [600, 400], {2, 7}, {'cccc': 10})""" + String sql1 = "delete from ${tableName2} where id<=2;" + explain { + sql sql1 + contains "IS_PARTIAL_UPDATE: true" + } + sql(sql1) + + qt_sql """ select *,__DORIS_VERSION_COL__,__DORIS_DELETE_SIGN__ from ${tableName2} order by id,__DORIS_VERSION_COL__;""" + sql "set skip_delete_bitmap=true;" + sql "set skip_delete_sign=true;" + qt_sql """ select *,__DORIS_VERSION_COL__,__DORIS_DELETE_SIGN__ from ${tableName2} order by id,__DORIS_VERSION_COL__;""" + sql "set skip_delete_bitmap=false;" + sql "set skip_delete_sign=false;" } } }