[cherry-pick](branch-2.1) Pick "[Enhancement](partial update) Add some partial update case (#36385)" (#37382)
#36385
This commit is contained in:
@ -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"}
|
||||
|
||||
@ -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
|
||||
|
||||
5
regression-test/data/delete_p0/test_new_delete.out
Normal file
5
regression-test/data/delete_p0/test_new_delete.out
Normal file
@ -0,0 +1,5 @@
|
||||
-- This file is automatically generated. You should know what you did if you want to edit this
|
||||
-- !select1 --
|
||||
|
||||
-- !select2 --
|
||||
|
||||
4
regression-test/data/insert_p0/test_txn.out
Normal file
4
regression-test/data/insert_p0/test_txn.out
Normal file
@ -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"}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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"}
|
||||
|
||||
69
regression-test/data/unique_with_mow_p0/test_delete_sign.out
Normal file
69
regression-test/data/unique_with_mow_p0/test_delete_sign.out
Normal file
@ -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"}
|
||||
|
||||
4
regression-test/data/update/test_new_update.out
Normal file
4
regression-test/data/update/test_new_update.out
Normal file
@ -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"}
|
||||
|
||||
@ -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}"
|
||||
}
|
||||
@ -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"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
61
regression-test/suites/delete_p0/test_new_delete.groovy
Normal file
61
regression-test/suites/delete_p0/test_new_delete.groovy
Normal file
@ -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}"
|
||||
}
|
||||
43
regression-test/suites/insert_p0/test_txn.groovy
Normal file
43
regression-test/suites/insert_p0/test_txn.groovy
Normal file
@ -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}"
|
||||
|
||||
}
|
||||
@ -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."))
|
||||
}
|
||||
}
|
||||
@ -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};"
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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};"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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};"
|
||||
}
|
||||
}
|
||||
}
|
||||
42
regression-test/suites/update/test_new_update.groovy
Normal file
42
regression-test/suites/update/test_new_update.groovy
Normal file
@ -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}"
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user