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 000000000000000..00a59ea8287a3aa --- /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 000000000000000..95c607fdabba76a --- /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/insert_p0/test_txn.out b/regression-test/data/insert_p0/test_txn.out new file mode 100644 index 000000000000000..939f6ae4f4b855c --- /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_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 000000000000000..7ddbe783e7e6d3a --- /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 000000000000000..60bf812800b589e --- /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 000000000000000..f84cc810a0debb9 --- /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 000000000000000..e05946080a53952 --- /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 000000000000000..8c2956b38c51a4a --- /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/insert_p0/test_txn.groovy b/regression-test/suites/insert_p0/test_txn.groovy new file mode 100644 index 000000000000000..799adba144543e6 --- /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/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 000000000000000..f72160bb594ee90 --- /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 000000000000000..c067b757c091a2d --- /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 000000000000000..2cb85cb2e739912 --- /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