This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 666daad650a2f9a08341dc83661baaaa4bce918c Author: Kaijie Chen <c...@apache.org> AuthorDate: Fri Jul 28 17:36:55 2023 +0800 [test](regression) add partial update seq_col delete cases (#22340) --- .../test_partial_update_seq_col_delete.out | 14 ++ .../test_partial_update_seq_type_delete.out | 29 ++++ .../test_partial_update_seq_col_delete.groovy | 105 ++++++++++++ .../test_partial_update_seq_type_delete.groovy | 182 +++++++++++++++++++++ 4 files changed, 330 insertions(+) diff --git a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_seq_col_delete.out b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_seq_col_delete.out new file mode 100644 index 0000000000..0c9853eece --- /dev/null +++ b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_seq_col_delete.out @@ -0,0 +1,14 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_default -- +1 doris 1000 123 1 2023-01-01 +2 doris2 2000 223 1 2023-01-01 + +-- !partial_update_without_seq -- + +-- !partial_update_with_seq -- + +-- !partial_update_with_seq_hidden_columns -- +1 unknown 1300 \N 4321 2022-07-19 1 4 2022-07-19 +2 unknown 2600 \N 4321 2023-07-20 1 4 2023-07-20 +3 unknown 1500 \N 4321 2022-07-20 1 4 2022-07-20 + diff --git a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_seq_type_delete.out b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_seq_type_delete.out new file mode 100644 index 0000000000..1db781e633 --- /dev/null +++ b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_seq_type_delete.out @@ -0,0 +1,29 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_default -- +1 doris 1000 123 1 2023-01-01 +2 doris2 2000 223 1 2023-01-01 + +-- !partial_update_with_seq_score -- + +-- !partial_update_with_seq_score_hidden -- +1 unknown 2300 2300 4321 2021-05-19 1 3 2300 +2 unknown 3600 2400 4321 2019-01-23 1 3 3600 +3 unknown 2000 2400 4321 2022-02-18 1 3 2000 + +-- !partial_update_with_seq_test -- + +-- !partial_update_with_seq_test_hidden -- +1 unknown 2300 2300 4321 2021-05-19 1 4 2300 +2 unknown 3600 2400 4321 2019-01-23 1 3 3600 +3 unknown 1500 2500 4321 2022-03-31 1 4 2500 + +-- !select_no_partial_update_score -- +1 unknown 2300 2350 4321 2021-05-18 1 5 2300 +2 unknown 3650 2450 4321 2019-01-22 1 5 3650 +3 unknown 1500 2500 4321 2022-03-31 1 4 2500 + +-- !select_no_partial_update_test -- +1 unknown 2300 2350 4321 2021-05-18 1 6 2350 +2 unknown 3650 2450 4321 2019-01-22 1 5 3650 +3 unknown 1550 2550 4321 2022-03-30 1 6 2550 + diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_seq_col_delete.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_seq_col_delete.groovy new file mode 100644 index 0000000000..79b7ca7831 --- /dev/null +++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_seq_col_delete.groovy @@ -0,0 +1,105 @@ + +// 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_seq_col_delete", "p0") { + def tableName = "test_primary_key_partial_update_seq_col_delete" + + // create table + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ + CREATE TABLE ${tableName} ( + `id` int(11) NOT NULL COMMENT "用户 ID", + `name` varchar(65533) DEFAULT "unknown" COMMENT "用户姓名", + `score` int(11) NOT NULL COMMENT "用户得分", + `test` int(11) NULL COMMENT "null test", + `dft` int(11) DEFAULT "4321", + `update_time` date NULL) + UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 1 + PROPERTIES( + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true", + "function_column.sequence_col" = "update_time" + ) + """ + // insert 2 lines + sql """ + insert into ${tableName} values + (2, "doris2", 2000, 223, 1, '2023-01-01'), + (1, "doris", 1000, 123, 1, '2023-01-01') + """ + + sql "sync" + + qt_select_default """ + select * from ${tableName} order by id; + """ + + // set partial update header, should success + // we don't provide the sequence column in input data, so the updated rows + // should use there original sequence column values. + streamLoad { + table "${tableName}" + + set 'column_separator', ',' + set 'format', 'csv' + set 'partial_columns', 'true' + set 'columns', 'id,score' + set 'merge_type', 'DELETE' + + file 'basic.csv' + time 10000 // limit inflight 10s + } + + sql "sync" + + qt_partial_update_without_seq """ + select * from ${tableName} order by id; + """ + + // provide the sequence column this time, should update according to the + // given sequence values + streamLoad { + table "${tableName}" + + set 'column_separator', ',' + set 'format', 'csv' + set 'partial_columns', 'true' + set 'columns', 'id,score,update_time' + set 'merge_type', 'DELETE' + + file 'basic_with_seq.csv' + time 10000 // limit inflight 10s + } + + sql "sync" + + qt_partial_update_with_seq """ + select * from ${tableName} order by id; + """ + + sql "SET show_hidden_columns=true" + + sql "sync" + + qt_partial_update_with_seq_hidden_columns """ + select * from ${tableName} order by id; + """ + + // drop drop + sql """ DROP TABLE IF EXISTS ${tableName} """ +} diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_seq_type_delete.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_seq_type_delete.groovy new file mode 100644 index 0000000000..90985616bb --- /dev/null +++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_seq_type_delete.groovy @@ -0,0 +1,182 @@ + +// 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_seq_type_delete", "p0") { + def tableName = "test_primary_key_partial_update_seq_type_delete" + + // create table + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ + CREATE TABLE ${tableName} ( + `id` int(11) NOT NULL COMMENT "用户 ID", + `name` varchar(65533) DEFAULT "unknown" COMMENT "用户姓名", + `score` int(11) NOT NULL COMMENT "用户得分", + `test` int(11) NULL COMMENT "null test", + `dft` int(11) DEFAULT "4321", + `update_time` date NULL) + UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 1 + PROPERTIES( + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true", + "function_column.sequence_type" = "int" + ) + """ + // insert 2 lines + sql """ + insert into ${tableName} values + (2, "doris2", 2000, 223, 1, '2023-01-01'), + (1, "doris", 1000, 123, 1, '2023-01-01') + """ + + sql "sync" + + qt_select_default """ + select * from ${tableName} order by id; + """ + + // no sequence column header, stream load should fail + streamLoad { + table "${tableName}" + + set 'column_separator', ',' + set 'format', 'csv' + set 'partial_columns', 'true' + set 'columns', 'id,score,test,update_time' + set 'merge_type', 'DELETE' + + file 'basic_with_test.csv' + time 10000 // limit inflight 10s + + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("fail", json.Status.toLowerCase()) + assertTrue(json.Message.contains('need to specify the sequence column')) + } + } + + sql "sync" + + // both partial_columns and sequence column header, stream load should success + streamLoad { + table "${tableName}" + + set 'column_separator', ',' + set 'format', 'csv' + set 'partial_columns', 'true' + set 'columns', 'id,score,test,update_time' + set 'function_column.sequence_col', 'score' + set 'merge_type', 'DELETE' + + file 'basic_with_test.csv' + time 10000 // limit inflight 10s + } + + sql "sync" + + qt_partial_update_with_seq_score """ + select * from ${tableName} order by id; + """ + + sql "SET show_hidden_columns=true" + + sql "sync" + + qt_partial_update_with_seq_score_hidden """ + select * from ${tableName} order by id; + """ + + // use test as sequence column + streamLoad { + table "${tableName}" + + set 'column_separator', ',' + set 'format', 'csv' + set 'partial_columns', 'true' + set 'columns', 'id,score,test,update_time' + set 'function_column.sequence_col', 'test' + set 'merge_type', 'DELETE' + + file 'basic_with_test.csv' + time 10000 // limit inflight 10s + } + + sql "SET show_hidden_columns=false" + + sql "sync" + + qt_partial_update_with_seq_test """ + select * from ${tableName} order by id; + """ + + sql "SET show_hidden_columns=true" + + sql "sync" + + qt_partial_update_with_seq_test_hidden """ + select * from ${tableName} order by id; + """ + + // no partial update header, stream load should success, + // but the missing columns will be filled with default values + streamLoad { + table "${tableName}" + + set 'column_separator', ',' + set 'format', 'csv' + set 'columns', 'id,score,test,update_time' + set 'function_column.sequence_col', 'score' + set 'merge_type', 'DELETE' + + file 'basic_with_test2.csv' + time 10000 // limit inflight 10s + } + + sql "sync" + + qt_select_no_partial_update_score """ + select * from ${tableName} order by id; + """ + + // no partial update header, stream load should success, + // but the missing columns will be filled with default values + streamLoad { + table "${tableName}" + + set 'column_separator', ',' + set 'format', 'csv' + set 'columns', 'id,score,test,update_time' + set 'function_column.sequence_col', 'test' + set 'merge_type', 'DELETE' + + file 'basic_with_test2.csv' + time 10000 // limit inflight 10s + } + + sql "sync" + + qt_select_no_partial_update_test """ + select * from ${tableName} order by id; + """ + + // drop table + sql """ DROP TABLE IF EXISTS ${tableName} """ +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org