Skip to content

Commit a6eb348

Browse files
authored
add upgrade case for flexible partial update (apache#184)
* add upgrade case * add downgrade case
1 parent a14c78e commit a6eb348

8 files changed

Lines changed: 440 additions & 0 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !sql --
3+
0 0 0 0 0 0
4+
1 10 111 111 1 1
5+
2 2 20 2 222 25
6+
3 3 3 30 3 3
7+
4 43 4 99 20 4
8+
5 5 5 5 5 \N
9+
6 999 6 777 6 6
10+
7 7 7 7 7 7
11+
8 8 8 8 8 8
12+
9 9 9 9 9 9
13+
14+
-- !sql --
15+
0 0 0 0 0 0
16+
1 999 111 999 1 999
17+
2 888 20 888 222 888
18+
3 3 3 30 3 3
19+
4 43 4 99 20 4
20+
5 777 5 777 5 777
21+
6 999 6 777 6 6
22+
7 7 7 7 7 7
23+
8 8 8 8 8 8
24+
9 9 9 9 9 9
25+
20 555 9876 555 1234 555
26+
27+
-- !sql --
28+
0 0 0 0 0 0
29+
1 999 111 999 1 999
30+
2 888 20 888 222 888
31+
7 7 7 7 7 7
32+
8 8 8 8 8 8
33+
9 9 9 9 9 9
34+
20 555 9876 555 1234 555
35+
36+
-- !sql --
37+
0 0 0 0 0 0
38+
1 999 111 999 1 999
39+
2 888 20 888 222 888
40+
3 10 10 10 10 10
41+
4 12 12 12 12 12
42+
7 7 7 7 7 7
43+
8 8 8 8 8 8
44+
9 9 9 9 9 9
45+
20 555 9876 555 1234 555
46+
30 11 11 11 11 11
47+
48+
-- !sql --
49+
0 0 0 0 0 0
50+
1 10 111 111 1 1
51+
2 2 20 2 222 25
52+
3 3 3 30 3 3
53+
4 43 4 99 20 4
54+
5 5 5 5 5 \N
55+
6 999 6 777 6 6
56+
7 7 7 7 7 7
57+
8 8 8 8 8 8
58+
9 9 9 9 9 9
59+
60+
-- !sql --
61+
0 0 0 0 0 0
62+
1 999 111 999 1 999
63+
2 888 20 888 222 888
64+
3 3 3 30 3 3
65+
4 43 4 99 20 4
66+
5 777 5 777 5 777
67+
6 999 6 777 6 6
68+
7 7 7 7 7 7
69+
8 8 8 8 8 8
70+
9 9 9 9 9 9
71+
20 555 9876 555 1234 555
72+
73+
-- !sql --
74+
0 0 0 0 0 0
75+
1 999 111 999 1 999
76+
2 888 20 888 222 888
77+
7 7 7 7 7 7
78+
8 8 8 8 8 8
79+
9 9 9 9 9 9
80+
20 555 9876 555 1234 555
81+
82+
-- !sql --
83+
0 0 0 0 0 0
84+
1 999 111 999 1 999
85+
2 888 20 888 222 888
86+
3 10 10 10 10 10
87+
4 12 12 12 12 12
88+
7 7 7 7 7 7
89+
8 8 8 8 8 8
90+
9 9 9 9 9 9
91+
20 555 9876 555 1234 555
92+
30 11 11 11 11 11
93+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{"k": 1, "v1": 10}
2+
{"k": 2, "v2": 20, "v5": 25}
3+
{"k": 3, "v3": 30}
4+
{"k": 4, "v4": 20, "v1": 43, "v3": 99}
5+
{"k": 5, "v5": null}
6+
{"k": 6, "v1": 999, "v3": 777}
7+
{"k": 2, "v4": 222}
8+
{"k": 1, "v2": 111, "v3": 111}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !sql --
3+
0 0 0 0 0 0
4+
1 1 1 1 1 1
5+
2 2 2 2 2 2
6+
3 3 3 3 3 3
7+
4 4 4 4 4 4
8+
5 5 5 5 5 5
9+
6 6 6 6 6 6
10+
7 7 7 7 7 7
11+
8 8 8 8 8 8
12+
9 9 9 9 9 9
13+
14+
-- !sql --
15+
0 0 0 0 0 0
16+
1 10 111 111 1 1 4,5,6
17+
2 2 20 2 222 25 1,3,6
18+
3 3 3 30 3 3 1,2,4,5,6
19+
4 43 4 99 20 4 2,5,6
20+
5 5 5 5 5 \N 1,2,3,4,6
21+
6 999 6 777 6 6 2,4,5,6
22+
7 7 7 7 7 7
23+
8 8 8 8 8 8
24+
9 9 9 9 9 9
25+
26+
-- !sql --
27+
0 0 0 0 0 0
28+
1 999 111 999 1 999
29+
2 888 20 888 222 888
30+
3 3 3 30 3 3
31+
4 43 4 99 20 4
32+
5 777 5 777 5 777
33+
6 999 6 777 6 6
34+
7 7 7 7 7 7
35+
8 8 8 8 8 8
36+
9 9 9 9 9 9
37+
20 555 9876 555 1234 555
38+
39+
-- !sql --
40+
0 0 0 0 0 0
41+
1 999 111 999 1 999
42+
2 888 20 888 222 888
43+
7 7 7 7 7 7
44+
8 8 8 8 8 8
45+
9 9 9 9 9 9
46+
20 555 9876 555 1234 555
47+
48+
-- !sql --
49+
0 0 0 0 0 0
50+
1 999 111 999 1 999
51+
2 888 20 888 222 888
52+
3 10 10 10 10 10
53+
4 12 12 12 12 12
54+
7 7 7 7 7 7
55+
8 8 8 8 8 8
56+
9 9 9 9 9 9
57+
20 555 9876 555 1234 555
58+
30 11 11 11 11 11
59+
60+
-- !sql --
61+
0 0 0 0 0 0
62+
1 1 1 1 1 1
63+
2 2 2 2 2 2
64+
3 3 3 3 3 3
65+
4 4 4 4 4 4
66+
5 5 5 5 5 5
67+
6 6 6 6 6 6
68+
7 7 7 7 7 7
69+
8 8 8 8 8 8
70+
9 9 9 9 9 9
71+
72+
-- !sql --
73+
0 0 0 0 0 0
74+
1 10 111 111 1 1 4,5,6
75+
2 2 20 2 222 25 1,3,6
76+
3 3 3 30 3 3 1,2,4,5,6
77+
4 43 4 99 20 4 2,5,6
78+
5 5 5 5 5 \N 1,2,3,4,6
79+
6 999 6 777 6 6 2,4,5,6
80+
7 7 7 7 7 7
81+
8 8 8 8 8 8
82+
9 9 9 9 9 9
83+
84+
-- !sql --
85+
0 0 0 0 0 0
86+
1 999 111 999 1 999
87+
2 888 20 888 222 888
88+
3 3 3 30 3 3
89+
4 43 4 99 20 4
90+
5 777 5 777 5 777
91+
6 999 6 777 6 6
92+
7 7 7 7 7 7
93+
8 8 8 8 8 8
94+
9 9 9 9 9 9
95+
20 555 9876 555 1234 555
96+
97+
-- !sql --
98+
0 0 0 0 0 0
99+
1 999 111 999 1 999
100+
2 888 20 888 222 888
101+
7 7 7 7 7 7
102+
8 8 8 8 8 8
103+
9 9 9 9 9 9
104+
20 555 9876 555 1234 555
105+
106+
-- !sql --
107+
0 0 0 0 0 0
108+
1 999 111 999 1 999
109+
2 888 20 888 222 888
110+
3 10 10 10 10 10
111+
4 12 12 12 12 12
112+
7 7 7 7 7 7
113+
8 8 8 8 8 8
114+
9 9 9 9 9 9
115+
20 555 9876 555 1234 555
116+
30 11 11 11 11 11
117+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{"k": 1, "v1": 10}
2+
{"k": 2, "v2": 20, "v5": 25}
3+
{"k": 3, "v3": 30}
4+
{"k": 4, "v4": 20, "v1": 43, "v3": 99}
5+
{"k": 5, "v5": null}
6+
{"k": 6, "v1": 999, "v3": 777}
7+
{"k": 2, "v4": 222}
8+
{"k": 1, "v2": 111, "v3": 111}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite('test_flexible_partial_update_downgrade_base_data', 'p0,restart_fe') {
19+
String db = context.config.getDbNameByFile(context.file)
20+
for (def use_row_store : [false, true]) {
21+
logger.info("current params: use_row_store: ${use_row_store}")
22+
def tableName = "test_f_downgrade_${use_row_store}"
23+
24+
sql "use ${db};"
25+
def tbls = sql "show tables;"
26+
boolean shouldSkip = false
27+
for (def tbl : tbls) {
28+
if (tbl[0] == tableName) {
29+
logger.info("skip to create table ${tableName};")
30+
shouldSkip = true
31+
break;
32+
}
33+
}
34+
if (shouldSkip) {
35+
continue
36+
}
37+
38+
sql """ DROP TABLE IF EXISTS ${tableName} """
39+
sql """ CREATE TABLE ${tableName} (
40+
`k` int(11) NULL,
41+
`v1` BIGINT NULL,
42+
`v2` BIGINT NULL DEFAULT "9876",
43+
`v3` BIGINT NOT NULL,
44+
`v4` BIGINT NOT NULL DEFAULT "1234",
45+
`v5` BIGINT NULL
46+
) UNIQUE KEY(`k`) DISTRIBUTED BY HASH(`k`) BUCKETS 1
47+
PROPERTIES(
48+
"replication_num" = "1",
49+
"enable_unique_key_merge_on_write" = "true",
50+
"light_schema_change" = "true",
51+
"enable_unique_key_skip_bitmap_column" = "true",
52+
"store_row_column" = "${use_row_store}"); """
53+
54+
sql """insert into ${tableName} select number, number, number, number, number, number from numbers("number" = "10"); """
55+
streamLoad {
56+
table "${tableName}"
57+
set 'format', 'json'
58+
set 'read_json_by_line', 'true'
59+
set 'strict_mode', 'false'
60+
set 'unique_key_update_mode', 'UPDATE_FLEXIBLE_COLUMNS'
61+
file "test1.json"
62+
time 20000
63+
}
64+
}
65+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite('test_flexible_partial_update_downgrade', 'p0,restart_fe') {
19+
String db = context.config.getDbNameByFile(context.file)
20+
for (def use_row_store : [false, true]) {
21+
logger.info("current params: use_row_store: ${use_row_store}")
22+
def tableName = "test_f_downgrade_${use_row_store}"
23+
qt_sql "select k,v1,v2,v3,v4,v5 from ${tableName} order by k;"
24+
25+
sql "set enable_unique_key_partial_update=true;"
26+
sql "set enable_insert_strict=false;"
27+
sql "sync;"
28+
sql "insert into ${tableName}(k,v1,v3,v5) values(1,999,999,999),(2,888,888,888),(5,777,777,777),(20,555,555,555);"
29+
sql "set enable_unique_key_partial_update=false;"
30+
sql "set enable_insert_strict=true;"
31+
sql "sync;"
32+
qt_sql "select k,v1,v2,v3,v4,v5 from ${tableName} order by k;"
33+
34+
sql "delete from ${tableName} where k>=3 and k<=6;"
35+
qt_sql "select k,v1,v2,v3,v4,v5 from ${tableName} order by k;"
36+
37+
sql "insert into ${tableName} values(3,10,10,10,10,10),(30,11,11,11,11,11),(4,12,12,12,12,12);"
38+
qt_sql "select k,v1,v2,v3,v4,v5 from ${tableName} order by k;"
39+
}
40+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite('test_flexible_partial_update_upgrade_base_data', 'p0,restart_fe') {
19+
String db = context.config.getDbNameByFile(context.file)
20+
for (def use_row_store : [false, true]) {
21+
logger.info("current params: use_row_store: ${use_row_store}")
22+
def tableName = "test_f_upgrade_${use_row_store}"
23+
24+
sql "use ${db};"
25+
def tbls = sql "show tables;"
26+
boolean shouldSkip = false
27+
for (def tbl : tbls) {
28+
if (tbl[0] == tableName) {
29+
logger.info("skip to create table ${tableName};")
30+
shouldSkip = true
31+
break;
32+
}
33+
}
34+
if (shouldSkip) {
35+
continue
36+
}
37+
38+
sql """ DROP TABLE IF EXISTS ${tableName} """
39+
sql """ CREATE TABLE ${tableName} (
40+
`k` int(11) NULL,
41+
`v1` BIGINT NULL,
42+
`v2` BIGINT NULL DEFAULT "9876",
43+
`v3` BIGINT NOT NULL,
44+
`v4` BIGINT NOT NULL DEFAULT "1234",
45+
`v5` BIGINT NULL
46+
) UNIQUE KEY(`k`) DISTRIBUTED BY HASH(`k`) BUCKETS 1
47+
PROPERTIES(
48+
"replication_num" = "1",
49+
"enable_unique_key_merge_on_write" = "true",
50+
"light_schema_change" = "true",
51+
"store_row_column" = "${use_row_store}"); """
52+
53+
sql """insert into ${tableName} select number, number, number, number, number, number from numbers("number" = "10"); """
54+
}
55+
}

0 commit comments

Comments
 (0)