Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](case) fix test_schema_change_ck #41654

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions regression-test/data/unique_with_mow_c_p0/test_schema_change_ck.out
Original file line number Diff line number Diff line change
Expand Up @@ -154,28 +154,28 @@
210 200 39 20

-- !select_create_mv_mv --
10 39
11 38
110 39
111 38
112 37
113 36
114 35
115 34
116 33
117 32
118 31
119 30
12 37
13 36
14 35
15 34
16 33
17 32
18 31
19 30
210 39
211 38
10 \N 29
11 \N 28
110 200 20
111 200 21
112 200 22
113 200 23
114 200 24
115 200 25
116 200 20
117 200 20
118 200 20
119 200 20
12 \N 26
13 \N 27
14 \N 20
15 \N 20
16 \N 20
17 \N 20
18 200 20
19 200 20
210 200 20
211 200 21

-- !select_create_rollup_base --
11 \N 38 28
Expand Down
102 changes: 102 additions & 0 deletions regression-test/suites/insert_p0/test_jdbc.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// 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.

import java.util.Arrays
import java.util.stream.Collectors

suite("test_jdbc") {
def user = context.config.jdbcUser
def password = context.config.jdbcPassword
def realDb = "regression_test_insert_p0"
def tableName = realDb + ".test_jdbc"

sql "CREATE DATABASE IF NOT EXISTS ${realDb}"
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
CREATE TABLE ${tableName} (
`id` int(11) NULL,
`phone` varchar(50) NULL,
) ENGINE=OLAP
unique KEY(`id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);
"""

// Parse url
String jdbcUrl = context.config.jdbcUrl
String urlWithoutSchema = jdbcUrl.substring(jdbcUrl.indexOf("://") + 3)
def sql_ip = urlWithoutSchema.substring(0, urlWithoutSchema.indexOf(":"))
def sql_port
if (urlWithoutSchema.indexOf("/") >= 0) {
// e.g: jdbc:mysql://localhost:8080/?a=b
sql_port = urlWithoutSchema.substring(urlWithoutSchema.indexOf(":") + 1, urlWithoutSchema.indexOf("/"))
} else {
// e.g: jdbc:mysql://localhost:8080
sql_port = urlWithoutSchema.substring(urlWithoutSchema.indexOf(":") + 1)
}
String url = String.format("jdbc:mysql://%s:%s/%s?useLocalSessionState=true", sql_ip, sql_port, realDb)
def batchSize = 5

def urls = [
url,
url + "&rewriteBatchedStatements=true",
url + "&rewriteBatchedStatements=true&allowMultiQueries=true",
url + "&rewriteBatchedStatements=true&allowMultiQueries=false"
]

def insert = { jdbc_url ->
connect(user = user, password = password, url = jdbc_url) {
logger.info("insert url: {}", jdbc_url)
def ps = prepareStatement "insert into ${tableName} values(?, ?)"
for (int i = 0; i < batchSize; i++) {
String phone = UUID.randomUUID().toString()
ps.setInt(1, i + 1)
ps.setString(2, phone)
logger.info((i + 1) + ", " + phone)
ps.addBatch()
}
int[] results = ps.executeBatch()
logger.info("insert results: {}", Arrays.stream(results).boxed().map(i -> String.valueOf(i)).collect(Collectors.joining(", ")))
ps.close()
}
}

def update = { jdbc_url ->
connect(user = user, password = password, url = jdbc_url) {
logger.info("update url: {}", jdbc_url)
def ps = prepareStatement "update ${tableName} set phone = ? where id = ?";
for (int i = 0; i < batchSize; i++) {
String phone = UUID.randomUUID().toString()
ps.setInt(2, i + 1)
ps.setString(1, phone)
logger.info((i + 1) + ", " + phone)
ps.addBatch()
}
int[] results = ps.executeBatch()
logger.info("update results: {}", Arrays.stream(results).boxed().map(i -> String.valueOf(i)).collect(Collectors.joining(", ")))
ps.close()
}
}

for (final def jdbc_url in urls) {
insert(jdbc_url)
update(jdbc_url)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ suite("test_schema_change_ck") {
/****** create mv ******/
def mv_name = "k2_c3"
sql """DROP MATERIALIZED VIEW IF EXISTS ${mv_name}"""
createMV """ create materialized view ${mv_name} as select c1, c3 from ${tableName}; """
createMV """ create materialized view ${mv_name} as select c1, k2, c2 from ${tableName}; """
sql """ INSERT INTO ${tableName}(c1, c2, c3, k2) VALUES (211, 21, 38, 200), (210, 20, 39, 200) """
qt_select_create_mv_base """select * from ${tableName}"""
/*Awaitility.await().atMost(100, SECONDS).pollInterval(4, SECONDS).until(
Expand All @@ -156,7 +156,7 @@ suite("test_schema_change_ck") {
return result.contains(mv_name)
}
)*/
order_qt_select_create_mv_mv """select c1, c3 from ${tableName}"""
order_qt_select_create_mv_mv """select c1, k2, c2 from ${tableName}"""

/****** create rollup ******/
sql """ alter table ${tableName} ADD ROLLUP r1(k2, c1, c2); """
Expand Down
Loading