This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new f32e248a89f [Enhancement](partial update) Add some partial update case (#36385) f32e248a89f is described below commit f32e248a89f328101c8e754f8e35ff2bf10c2900 Author: abmdocrt <yukang.lian2...@gmail.com> AuthorDate: Wed Jun 19 09:52:45 2024 +0800 [Enhancement](partial update) Add some partial update case (#36385) --- .../data_model_p0/unique/test_default_value.out | 9 ++ .../data_model_p0/unique/test_sequence_column.out | 7 ++ regression-test/data/delete_p0/test_new_delete.out | 5 + regression-test/data/insert_p0/test_txn.out | 4 + .../partial_update/test_partial_update.out | 6 + .../test_partial_update_with_inverted_index.out | 13 ++ .../data/unique_with_mow_p0/test_delete_sign.out | 69 +++++++++++ regression-test/data/update/test_new_update.out | 4 + .../data_model_p0/unique/test_default_value.groovy | 61 ++++++++++ .../unique/test_sequence_column.groovy | 88 ++++++++++++++ .../suites/delete_p0/test_new_delete.groovy | 61 ++++++++++ regression-test/suites/insert_p0/test_txn.groovy | 43 +++++++ .../schema_change_p0/test_new_schema_change.groovy | 49 ++++++++ .../partial_update/test_partial_update.groovy | 25 ++++ .../test_partial_update_with_inverted_index.groovy | 60 ++++++++++ .../unique_with_mow_p0/test_delete_sign.groovy | 133 +++++++++++++++++++++ .../suites/update/test_new_update.groovy | 42 +++++++ 17 files changed, 679 insertions(+) diff --git a/regression-test/data/data_model_p0/unique/test_default_value.out b/regression-test/data/data_model_p0/unique/test_default_value.out new file mode 100644 index 00000000000..00a59ea8287 --- /dev/null +++ b/regression-test/data/data_model_p0/unique/test_default_value.out @@ -0,0 +1,9 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select1 -- +1 1 3 a + +-- !select2 -- +1 1 3 \N +2 2 4 \N +3 3 3 {"b":"b"} + diff --git a/regression-test/data/data_model_p0/unique/test_sequence_column.out b/regression-test/data/data_model_p0/unique/test_sequence_column.out new file mode 100644 index 00000000000..95c607fdabb --- /dev/null +++ b/regression-test/data/data_model_p0/unique/test_sequence_column.out @@ -0,0 +1,7 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select1 -- +1 1 5 a + +-- !all -- +1 1 5 a + diff --git a/regression-test/data/delete_p0/test_new_delete.out b/regression-test/data/delete_p0/test_new_delete.out new file mode 100644 index 00000000000..642559699ac --- /dev/null +++ b/regression-test/data/delete_p0/test_new_delete.out @@ -0,0 +1,5 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select1 -- + +-- !select2 -- + diff --git a/regression-test/data/insert_p0/test_txn.out b/regression-test/data/insert_p0/test_txn.out new file mode 100644 index 00000000000..939f6ae4f4b --- /dev/null +++ b/regression-test/data/insert_p0/test_txn.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select1 -- +1 1 3 {"b":"b"} + diff --git a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update.out b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update.out index f827086539d..70c57c2555e 100644 --- a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update.out +++ b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update.out @@ -47,6 +47,9 @@ -- !select_date2 -- 2 +-- !select_update -- +B + -- !select_default -- 1 doris 200 123 1 2 doris2 400 223 1 @@ -95,3 +98,6 @@ -- !select_date2 -- 2 +-- !select_update -- +B + diff --git a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_with_inverted_index.out b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_with_inverted_index.out new file mode 100644 index 00000000000..7ddbe783e7e --- /dev/null +++ b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_with_inverted_index.out @@ -0,0 +1,13 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_1 -- +true 1 1 {"a":"a"} + +-- !select_2 -- +true 1 1 {"b":"b"} + +-- !select_1 -- +true 1 1 {"a":"a"} + +-- !select_2 -- +true 1 1 {"b":"b"} + diff --git a/regression-test/data/unique_with_mow_p0/test_delete_sign.out b/regression-test/data/unique_with_mow_p0/test_delete_sign.out new file mode 100644 index 00000000000..60bf812800b --- /dev/null +++ b/regression-test/data/unique_with_mow_p0/test_delete_sign.out @@ -0,0 +1,69 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_0 -- +true 1 10 {"c":"c"} + +-- !select_1 -- + +-- !select_2 -- + +-- !select_3 -- +true 1 10 {"c":"c"} + +-- !select_4 -- + +-- !select_5 -- + +-- !select_6 -- + +-- !select_7 -- +true 1 10 {"c":"c"} + +-- !select_8 -- +true 1 10 {"c":"c"} + +-- !select_9 -- +true 1 30 {"b":"b"} + +-- !select_10 -- +true 1 10 {"c":"c"} + +-- !select_11 -- +true 1 10 {"c":"c"} + +-- !select_12 -- +true 1 30 {"b":"b"} + +-- !select_0 -- +true 1 10 {"c":"c"} + +-- !select_1 -- + +-- !select_2 -- + +-- !select_3 -- +true 1 10 {"c":"c"} + +-- !select_4 -- + +-- !select_5 -- + +-- !select_6 -- + +-- !select_7 -- +true 1 10 {"c":"c"} + +-- !select_8 -- +true 1 10 {"c":"c"} + +-- !select_9 -- +true 1 30 {"b":"b"} + +-- !select_10 -- +true 1 10 {"c":"c"} + +-- !select_11 -- +true 1 10 {"c":"c"} + +-- !select_12 -- +true 1 30 {"b":"b"} + diff --git a/regression-test/data/update/test_new_update.out b/regression-test/data/update/test_new_update.out new file mode 100644 index 00000000000..f84cc810a0d --- /dev/null +++ b/regression-test/data/update/test_new_update.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select1 -- +1 1 3 {"c":"c"} + diff --git a/regression-test/suites/data_model_p0/unique/test_default_value.groovy b/regression-test/suites/data_model_p0/unique/test_default_value.groovy new file mode 100644 index 00000000000..e05946080a5 --- /dev/null +++ b/regression-test/suites/data_model_p0/unique/test_default_value.groovy @@ -0,0 +1,61 @@ +// 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_default_value") { + def tableName = "test_default_value" + // test default value X txn + sql "DROP TABLE IF EXISTS ${tableName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` bigint default 999, + `group_id` bigint, + `id` bigint, + `keyword` VARCHAR(128), + INDEX idx_col1 (user_id) USING INVERTED + ) ENGINE=OLAP + UNIQUE KEY(user_id, group_id) + DISTRIBUTED BY HASH (user_id) BUCKETS 1 + PROPERTIES( + "replication_num" = "1" + ); + """ + sql "begin" + sql "insert into ${tableName} values(1,1,5,'a'),(1,1,4,'a'),(1,1,3,'a')" + sql "commit" + + qt_select1 "SELECT * from ${tableName}" + + // test default value X variant + sql "DROP TABLE IF EXISTS ${tableName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` bigint, + `group_id` bigint, + `id` bigint, + `vv` variant default NULL + ) ENGINE=OLAP + UNIQUE KEY(user_id, group_id) + DISTRIBUTED BY HASH (user_id) BUCKETS 1 + PROPERTIES( + "replication_num" = "1" + ); + """ + sql """insert into ${tableName} (user_id, group_id, id) values (1,1,5),(2,2,4),(1,1,3)""" + sql """insert into ${tableName} values(3,3,3,'{"b":"b"}')""" + + qt_select2 "SELECT * from ${tableName}" +} diff --git a/regression-test/suites/data_model_p0/unique/test_sequence_column.groovy b/regression-test/suites/data_model_p0/unique/test_sequence_column.groovy new file mode 100644 index 00000000000..8c2956b38c5 --- /dev/null +++ b/regression-test/suites/data_model_p0/unique/test_sequence_column.groovy @@ -0,0 +1,88 @@ +// 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_sequence_column") { + // test sequence X inverted index + def tableName = "test_sequence_column" + sql "DROP TABLE IF EXISTS ${tableName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` bigint, + `group_id` bigint, + `id` bigint, + `keyword` VARCHAR(128), + INDEX idx_col1 (user_id) USING INVERTED + ) ENGINE=OLAP + UNIQUE KEY(user_id, group_id) + DISTRIBUTED BY HASH (user_id) BUCKETS 1 + PROPERTIES( + "function_column.sequence_col" = 'id', + "replication_num" = "1" + ); + """ + sql "insert into ${tableName} values(1,1,5,'a'),(1,1,4,'a'),(1,1,3,'a')" + + qt_select1 "SELECT * from ${tableName}" + + // test sequence X row store + sql "DROP TABLE IF EXISTS ${tableName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` bigint, + `group_id` bigint, + `id` bigint, + `keyword` VARCHAR(128), + INDEX idx_col1 (user_id) USING INVERTED + ) ENGINE=OLAP + UNIQUE KEY(user_id, group_id) + DISTRIBUTED BY HASH (user_id) BUCKETS 1 + PROPERTIES( + "function_column.sequence_col" = 'id', + "replication_num" = "1", + "store_row_column" = "true" + ); + """ + sql "insert into ${tableName} values(1,1,5,'a'),(1,1,4,'a'),(1,1,3,'a')" + + order_qt_all "SELECT * from ${tableName}" + + // test sequence X variant + sql "DROP TABLE IF EXISTS ${tableName}" + try{ + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` bigint, + `group_id` bigint, + `id` bigint, + `keyword` VARCHAR(128), + `var` variant, + INDEX idx_col1 (user_id) USING INVERTED + ) ENGINE=OLAP + UNIQUE KEY(user_id, group_id) + DISTRIBUTED BY HASH (user_id) BUCKETS 1 + PROPERTIES( + "function_column.sequence_col" = 'var', + "replication_num" = "1", + "store_row_column" = "true" + ); + """ + }catch(Exception e){ + assertTrue(e.getMessage().contains("Sequence type only support integer types and date types")) + } + +} + diff --git a/regression-test/suites/delete_p0/test_new_delete.groovy b/regression-test/suites/delete_p0/test_new_delete.groovy new file mode 100644 index 00000000000..77b023d3e6c --- /dev/null +++ b/regression-test/suites/delete_p0/test_new_delete.groovy @@ -0,0 +1,61 @@ +// 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_new_delete") { + def tableName = "test_new_delete" + // test delete X inverted index + sql "DROP TABLE IF EXISTS ${tableName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` bigint, + `group_id` bigint, + `id` bigint, + `keyword` VARCHAR(128), + INDEX idx_col1 (user_id) USING INVERTED + ) ENGINE=OLAP + UNIQUE KEY(user_id, group_id) + DISTRIBUTED BY HASH (user_id) BUCKETS 1 + PROPERTIES( + "replication_num" = "1" + ); + """ + sql "insert into ${tableName} values(1,1,5,'a'),(1,1,4,'a'),(1,1,3,'a')" + sql "delete from ${tableName} where user_id=1" + + qt_select1 "SELECT * from ${tableName}" + + // test delete X row store + sql "DROP TABLE IF EXISTS ${tableName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` bigint, + `group_id` bigint, + `id` bigint, + `keyword` VARCHAR(128) + ) ENGINE=OLAP + UNIQUE KEY(user_id, group_id) + DISTRIBUTED BY HASH (user_id) BUCKETS 1 + PROPERTIES( + "replication_num" = "1", + "store_row_column" = "true" + ); + """ + sql "insert into ${tableName} values(1,1,5,'a'),(1,1,4,'a'),(1,1,3,'a')" + sql "delete from ${tableName} where user_id=1" + + qt_select2 "SELECT * from ${tableName}" +} diff --git a/regression-test/suites/insert_p0/test_txn.groovy b/regression-test/suites/insert_p0/test_txn.groovy new file mode 100644 index 00000000000..799adba1445 --- /dev/null +++ b/regression-test/suites/insert_p0/test_txn.groovy @@ -0,0 +1,43 @@ +// 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_txn") { + def tableName = "test_txn" + // test txn X inverted index + sql "DROP TABLE IF EXISTS ${tableName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` bigint default 999, + `group_id` bigint, + `id` bigint, + `vv` variant, + INDEX idx_col1 (user_id) USING INVERTED + ) ENGINE=OLAP + UNIQUE KEY(user_id, group_id) + DISTRIBUTED BY HASH (user_id) BUCKETS 1 + PROPERTIES( + "store_row_column" = "true", + "replication_num" = "1" + ); + """ + sql "begin" + sql """insert into ${tableName} values(1,1,5,'{"b":"b"}'),(1,1,4,'{"b":"b"}'),(1,1,3,'{"b":"b"}')""" + sql "commit" + + qt_select1 "SELECT * from ${tableName}" + +} diff --git a/regression-test/suites/schema_change_p0/test_new_schema_change.groovy b/regression-test/suites/schema_change_p0/test_new_schema_change.groovy new file mode 100644 index 00000000000..7b9f6cdd508 --- /dev/null +++ b/regression-test/suites/schema_change_p0/test_new_schema_change.groovy @@ -0,0 +1,49 @@ +// 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_new_schema_change") { + def tbName = "test_new_schema_change" + + def getJobState = { tableName -> + def jobStateResult = sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """ + return jobStateResult[0][9] + } + + sql """ DROP TABLE IF EXISTS ${tbName} """ + sql """ + CREATE TABLE IF NOT EXISTS ${tbName} + ( + event_day DATE, + siteid INT DEFAULT '10', + citycode bigint, + username VARCHAR(32) DEFAULT '', + pv BIGINT DEFAULT '0' + ) + UNIQUE KEY(event_day,siteid) + DISTRIBUTED BY HASH(siteid) BUCKETS 5 + PROPERTIES("replication_num" = "1", "light_schema_change" = "true"); + """ + try{ + sql "begin" + sql """ insert into ${tbName} values('2021-11-01',1,1,'用户A',1),('2021-11-01',1,1,'用户B',1),('2021-11-01',1,1,'用户A',3),('2021-11-02',1,1,'用户A',1),('2021-11-02',1,1,'用户B',1),('2021-11-02',101,112332121,'用户B',112312),('2021-11-02',103,112332211,'用户B',112312); """ + sql """ alter table ${tbName} add column vv int after pv""" + sql "commit" + sql """ DROP TABLE ${tbName} """ + }catch (Exception e){ + assertTrue(e.getMessage().contains("This is in a transaction, only insert, commit, rollback is acceptable.")) + } +} diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update.groovy index a21b3dda741..9d2410a11d2 100644 --- a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update.groovy +++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update.groovy @@ -242,6 +242,31 @@ suite("test_primary_key_partial_update", "p0") { sql "INSERT INTO ${tableName}(`name`, `userid`, `corp_name`) VALUES ('test2', 1234567, 'B');" qt_select_date2 "select count(*) from ${tableName} where `ctime` > \"1970-01-01\"" + + // test partial update with update statement + // drop table + sql """ DROP TABLE IF EXISTS ${tableName} """ + + sql """ SET enable_nereids_planner=true; """ + sql """ CREATE TABLE ${tableName} ( + `name` VARCHAR(600) NULL, + `userid` INT NOT NULL, + `seq` BIGINT NOT NULL AUTO_INCREMENT(1), + `ctime` DATE DEFAULT CURRENT_DATE, + `corp_name` VARCHAR(600) NOT NULL + ) ENGINE = OLAP UNIQUE KEY(`name`, `userid`) COMMENT 'OLAP' DISTRIBUTED BY HASH(`name`) BUCKETS 10 + PROPERTIES ("replication_num" = "1", + "enable_unique_key_merge_on_write" = "true", + "store_row_column" = "${use_row_store}"); """ + + sql "set enable_unique_key_partial_update=true;" + sql "set enable_insert_strict=false;" + + sql "INSERT INTO ${tableName}(`name`, `userid`, `corp_name`) VALUES ('test1', 1234567, 'A');" + + sql "UPDATE ${tableName} set corp_name = 'B';" + qt_select_update "select corp_name from ${tableName};" + } } } diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_with_inverted_index.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_with_inverted_index.groovy new file mode 100644 index 00000000000..f72160bb594 --- /dev/null +++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_with_inverted_index.groovy @@ -0,0 +1,60 @@ + +// 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_partial_update_with_inverted_index", "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_partial_update_with_inverted_index" + // create table + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ CREATE TABLE ${tableName} ( + col1 BOOLEAN, + col2 TINYINT, + col3 SMALLINT, + col4 variant, + INDEX idx_col1 (`col1`) USING INVERTED, + INDEX idx_col2 (`col2`) USING INVERTED, + INDEX idx_col3 (`col3`) USING INVERTED, + INDEX idx_col4 (`col4`) USING INVERTED + ) unique key(col1, col2) distributed by hash(col1) buckets 1 + properties( + "replication_num" = "1", + "store_row_column" = "${use_row_store}" + ); """ + + sql """ + insert into ${tableName} values(true, 1, 1, '{"a":"a"}'); + """ + qt_select_1 "select * from ${tableName};" + + sql "set enable_unique_key_partial_update=true;" + sql "set enable_insert_strict=false;" + sql """ + insert into ${tableName} (col1, col2, col4)values(true, 1, '{"b":"b"}'); + """ + qt_select_2 "select * from ${tableName};" + } + } +} diff --git a/regression-test/suites/unique_with_mow_p0/test_delete_sign.groovy b/regression-test/suites/unique_with_mow_p0/test_delete_sign.groovy new file mode 100644 index 00000000000..c067b757c09 --- /dev/null +++ b/regression-test/suites/unique_with_mow_p0/test_delete_sign.groovy @@ -0,0 +1,133 @@ + +// 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_delete_sign", "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_delete_sign" + // test delete sigin X sequence column + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ CREATE TABLE ${tableName} ( + col1 BOOLEAN, + col2 INT, + col3 INT, + col4 variant + ) unique key(col1, col2) distributed by hash(col1) buckets 1 + properties( + "replication_num" = "1", + "function_column.sequence_col" = 'col3', + "store_row_column" = "${use_row_store}" + ); """ + + sql """insert into ${tableName} values(true, 1, 1, '{"a":"a"}');""" + sql """insert into ${tableName} values(true, 1, 10, '{"c":"c"}');""" + sql """insert into ${tableName} values(true, 1, 2, '{"b":"b"}');""" + qt_select_0 "select * from ${tableName};" + sql """insert into ${tableName} (col1,col2,col3,col4,__DORIS_DELETE_SIGN__)values(true, 1, 10, '{"c":"c"}',1);""" + qt_select_1 "select * from ${tableName};" + sql """insert into ${tableName} values(true, 1, 3, '{"c":"c"}');""" + qt_select_2 "select * from ${tableName};" + + // test delete sigin X update + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ CREATE TABLE ${tableName} ( + col1 BOOLEAN, + col2 INT, + col3 INT, + col4 variant + ) unique key(col1, col2) distributed by hash(col1) buckets 1 + properties( + "replication_num" = "1", + "function_column.sequence_col" = 'col3', + "store_row_column" = "${use_row_store}" + ); """ + + sql """insert into ${tableName} values(true, 1, 1, '{"a":"a"}');""" + sql """insert into ${tableName} values(true, 1, 10, '{"c":"c"}');""" + sql """insert into ${tableName} values(true, 1, 2, '{"b":"b"}');""" + qt_select_3 "select * from ${tableName};" + sql """insert into ${tableName} (col1,col2,col3,col4,__DORIS_DELETE_SIGN__)values(true, 1, 10, '{"c":"c"}',1);""" + qt_select_4 "select * from ${tableName};" + sql """insert into ${tableName} values(true, 1, 3, '{"c":"c"}');""" + qt_select_5 "select * from ${tableName};" + //sql """update ${tableName} set __DORIS_DELETE_SIGN__=0 where col3=10;""" + qt_select_6 "select * from ${tableName};" + sql """insert into ${tableName} values(true, 1, 5, '{"c":"c"}');""" + + // test delete sigin X default value + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ CREATE TABLE ${tableName} ( + col1 BOOLEAN, + col2 INT, + col3 INT, + col4 variant NULL + ) unique key(col1, col2) distributed by hash(col1) buckets 1 + properties( + "replication_num" = "1", + "function_column.sequence_col" = 'col3', + "store_row_column" = "${use_row_store}" + ); """ + + sql """insert into ${tableName} values(true, 1, 1, '{"a":"a"}');""" + sql """insert into ${tableName} values(true, 1, 10, '{"c":"c"}');""" + sql """insert into ${tableName} values(true, 1, 2, '{"b":"b"}');""" + qt_select_7 "select * from ${tableName};" + sql """insert into ${tableName} (col1,col2,col3)values(true, 1, 1);""" + qt_select_8 "select * from ${tableName};" + sql """insert into ${tableName} values(true, 1, 30, '{"b":"b"}');""" + qt_select_9 "select * from ${tableName};" + + // test delete sigin X txn + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ CREATE TABLE ${tableName} ( + col1 BOOLEAN, + col2 INT, + col3 INT, + col4 variant default NULL, + INDEX idx_col3 (`col3`) USING INVERTED, + ) unique key(col1, col2) distributed by hash(col1) buckets 1 + properties( + "replication_num" = "1", + "function_column.sequence_col" = 'col3', + "store_row_column" = "${use_row_store}" + ); """ + + sql """begin""" + sql """insert into ${tableName} values(true, 1, 1, '{"a":"a"}');""" + sql """insert into ${tableName} values(true, 1, 10, '{"c":"c"}');""" + sql """insert into ${tableName} values(true, 1, 2, '{"b":"b"}');""" + sql """commit""" + qt_select_10 "select * from ${tableName};" + sql """begin""" + sql """insert into ${tableName} (col1,col2,col3)values(true, 1, 1);""" + sql """commit""" + qt_select_11 "select * from ${tableName};" + sql """begin""" + sql """insert into ${tableName} values(true, 1, 30, '{"b":"b"}');""" + sql """commit""" + qt_select_12 "select * from ${tableName};" + } + } +} diff --git a/regression-test/suites/update/test_new_update.groovy b/regression-test/suites/update/test_new_update.groovy new file mode 100644 index 00000000000..2cb85cb2e73 --- /dev/null +++ b/regression-test/suites/update/test_new_update.groovy @@ -0,0 +1,42 @@ +// 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_new_update") { + def tableName = "test_new_update" + // test txn X inverted index + sql "DROP TABLE IF EXISTS ${tableName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` bigint default 999, + `group_id` bigint, + `id` bigint, + `vv` variant, + INDEX idx_col1 (user_id) USING INVERTED + ) ENGINE=OLAP + UNIQUE KEY(user_id, group_id) + DISTRIBUTED BY HASH (user_id) BUCKETS 1 + PROPERTIES( + "store_row_column" = "true", + "replication_num" = "1" + ); + """ + sql """insert into ${tableName} values(1,1,5,'{"b":"b"}'),(1,1,4,'{"b":"b"}'),(1,1,3,'{"b":"b"}')""" + sql """update ${tableName} set vv='{"c":"c"}'""" + + qt_select1 "SELECT * from ${tableName}" + +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org