Skip to content

Commit

Permalink
[test](partial update) add complex type regression cases for partial …
Browse files Browse the repository at this point in the history
…update (#28758)

NOTE: There's some issue for MAP type to work with row store, so in this PR we don't have cases for MAP type
Will add the support for MAP type in future.
  • Loading branch information
zhannngchen authored Dec 22, 2023
1 parent 172f684 commit 25dcf40
Show file tree
Hide file tree
Showing 9 changed files with 434 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2 [1,2,3,5,8,13]
1 [1,3,5,7,9,11]
4 [1,2,3,4,5]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2 {"name": "tom", "age": 35}
1 {"name": "micheal", "age": 28}
3 {"name": "kk", "age": 42}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2 {"count": 100}
1 {"num": 9}
5 {"answer": 42}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2 {100,1000}
1 {1, 10}
6 {1000000, 10000000}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 apache doris
2 apache doris 2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !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}

-- !update_jsonb --
1 apache doris {"name":"micheal","age":28} [100, 200] {"a": 1, "b": 2}
2 apache doris 2.0 {"name":"tom","age":35} [300, 400] {"a": 3, "b": 4}
3 \N {"name":"kk","age":42} [] \N

-- !update_array --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11] {"a": 1, "b": 2}
2 apache doris 2.0 {"name":"tom","age":35} [1, 2, 3, 5, 8, 13] {"a": 3, "b": 4}
3 \N {"name":"kk","age":42} [] \N
4 \N \N [1, 2, 3, 4, 5] \N

-- !update_struct --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11] {"a": 1, "b": 10}
2 apache doris 2.0 {"name":"tom","age":35} [1, 2, 3, 5, 8, 13] {"a": 100, "b": 1000}
3 \N {"name":"kk","age":42} [] \N
4 \N \N [1, 2, 3, 4, 5] \N
6 \N \N [] {"a": 1000000, "b": 10000000}

-- !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}

-- !update_jsonb --
1 apache doris {"name":"micheal","age":28} [100, 200] {"a": 1, "b": 2}
2 apache doris 2.0 {"name":"tom","age":35} [300, 400] {"a": 3, "b": 4}
3 \N {"name":"kk","age":42} [] \N

-- !update_array --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11] {"a": 1, "b": 2}
2 apache doris 2.0 {"name":"tom","age":35} [1, 2, 3, 5, 8, 13] {"a": 3, "b": 4}
3 \N {"name":"kk","age":42} [] \N
4 \N \N [1, 2, 3, 4, 5] \N

-- !update_struct --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11] {"a": 1, "b": 10}
2 apache doris 2.0 {"name":"tom","age":35} [1, 2, 3, 5, 8, 13] {"a": 100, "b": 1000}
3 \N {"name":"kk","age":42} [] \N
4 \N \N [1, 2, 3, 4, 5] \N
6 \N \N [] {"a": 1000000, "b": 10000000}

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !update_varchar --
1 apache doris \N
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444}

-- !update_jsonb --
1 apache doris {"name":"micheal","age":28}
2 apache doris 2.0 {"name":"tom","age":35}
3 \N {"name":"kk","age":42}

-- !update_varchar --
1 apache doris {"name":"micheal","age":28} \N
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444} [300, 400]
3 \N {"name":"kk","age":42} \N

-- !update_array --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11]
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444} [1, 2, 3, 5, 8, 13]
3 \N {"name":"kk","age":42} \N
4 \N \N [1, 2, 3, 4, 5]

-- !update_varchar --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11] \N
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444} [300, 400] {"a": 3, "b": 4}
3 \N {"name":"kk","age":42} \N \N
4 \N \N [1, 2, 3, 4, 5] \N

-- !update_struct --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11] {"a": 1, "b": 10}
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444} [300, 400] {"a": 100, "b": 1000}
3 \N {"name":"kk","age":42} \N \N
4 \N \N [1, 2, 3, 4, 5] \N
6 \N \N \N {"a": 1000000, "b": 10000000}

-- !update_varchar --
1 apache doris \N
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444}

-- !update_jsonb --
1 apache doris {"name":"micheal","age":28}
2 apache doris 2.0 {"name":"tom","age":35}
3 \N {"name":"kk","age":42}

-- !update_varchar --
1 apache doris {"name":"micheal","age":28} \N
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444} [300, 400]
3 \N {"name":"kk","age":42} \N

-- !update_array --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11]
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444} [1, 2, 3, 5, 8, 13]
3 \N {"name":"kk","age":42} \N
4 \N \N [1, 2, 3, 4, 5]

-- !update_varchar --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11] \N
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444} [300, 400] {"a": 3, "b": 4}
3 \N {"name":"kk","age":42} \N \N
4 \N \N [1, 2, 3, 4, 5] \N

-- !update_struct --
1 apache doris {"name":"micheal","age":28} [1, 3, 5, 7, 9, 11] {"a": 1, "b": 10}
2 apache doris 2.0 {"jsonk3":333,"jsonk4":444} [300, 400] {"a": 100, "b": 1000}
3 \N {"name":"kk","age":42} \N \N
4 \N \N [1, 2, 3, 4, 5] \N
6 \N \N \N {"a": 1000000, "b": 10000000}

Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@

// 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
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

suite("test_primary_key_partial_update_complex_type", "p0") {

String db = context.config.getDbNameByFile(context.file)
sql "select 1;" // to create database

for (def use_row_store : [false, true]) {
logger.info("current params: use_row_store: ${use_row_store}")

connect(user = context.config.jdbcUser, password = context.config.jdbcPassword, url = context.config.jdbcUrl) {
sql "use ${db};"
def tableName = "test_primary_key_partial_update_complex_type"
// NOTE:
// 1. variant type don't support partial update
// 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 """ CREATE TABLE ${tableName} (
`id` int(11) NOT NULL COMMENT "用户 ID",
`c_varchar` varchar(65533) NULL COMMENT "用户姓名",
`c_jsonb` JSONB NULL,
`c_array` ARRAY<INT> NULL DEFAULT "[]",
`c_struct` STRUCT<a:INT, b:INT> 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}"); """

// insert 2 lines
sql """
insert into ${tableName} values(2, "doris2", '{"jsonk3": 333, "jsonk4": 444}', [300, 400], {3, 4})
"""

sql """
insert into ${tableName} values(1, "doris1", '{"jsonk1": 123, "jsonk2": 456}', [100, 200], {1, 2})
"""

// update varchar column
streamLoad {
table "${tableName}"

set 'partial_columns', 'true'
set 'columns', 'id,c_varchar'

file 'complex_type/varchar.tsv'
time 10000 // limit inflight 10s
}

sql "sync"

qt_update_varchar"""
select * from ${tableName} order by id;
"""

// update jsonb column, update 2 rows, add 1 new row
streamLoad {
table "${tableName}"

set 'partial_columns', 'true'
set 'columns', 'id,c_jsonb'

file 'complex_type/jsonb.tsv'
time 10000 // limit inflight 10s
}

sql "sync"

qt_update_jsonb"""
select * from ${tableName} order by id;
"""

// update array column, update 2 rows, add 1 new row
streamLoad {
table "${tableName}"

set 'partial_columns', 'true'
set 'columns', 'id,c_array'

file 'complex_type/array.tsv'
time 10000 // limit inflight 10s
}

sql "sync"

qt_update_array"""
select * from ${tableName} order by id;
"""

// update struct column, update 2 rows, add 1 new row
streamLoad {
table "${tableName}"

set 'partial_columns', 'true'
set 'columns', 'id,c_struct'

file 'complex_type/struct.tsv'
time 10000 // limit inflight 10s
}

sql "sync"

qt_update_struct"""
select * from ${tableName} order by id;
"""

// drop table
sql """ DROP TABLE IF EXISTS ${tableName} """
}
}
}
Loading

0 comments on commit 25dcf40

Please sign in to comment.