sandynz commented on code in PR #19361: URL: https://github.com/apache/shardingsphere/pull/19361#discussion_r925144493
########## shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/opengauss/initdb.sql: ########## @@ -0,0 +1,38 @@ +/* + * 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. + */ + +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- 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. + +CREATE DATABASE scaling_it_0; +CREATE DATABASE scaling_it_1; +CREATE DATABASE scaling_it_2; +CREATE DATABASE scaling_it_3; +CREATE DATABASE scaling_it_4; +ALTER ROLE gaussdb CREATEDB REPLICATION; Review Comment: Could we create role/user and then grant privileges for it? Like PostgreSQL scaling IT ########## shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/proxy/ShardingSphereProxyDockerContainer.java: ########## @@ -44,9 +44,9 @@ public ShardingSphereProxyDockerContainer(final DatabaseType databaseType) { protected void configure() { withExposedPorts(3307); mapConfigurationFiles(); - if (DatabaseTypeUtil.isPostgreSQL(databaseType) || DatabaseTypeUtil.isOpenGauss(databaseType)) { + if (DatabaseTypeUtil.isPostgreSQL(databaseType)) { setWaitStrategy(new JDBCConnectionWaitStrategy(() -> DriverManager.getConnection(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), "postgres"), "root", "root"))); Review Comment: Does it means openGauss case doesn't need to wait proxy ready? ########## shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/generator/PipelineDDLGenerator.java: ########## @@ -225,6 +225,10 @@ private Optional<String> decorateOpenGauss(final DatabaseType databaseType, fina if (logicSQL.toLowerCase().startsWith(SET_SEARCH_PATH_PREFIX)) { return Optional.empty(); } - return Optional.of(replaceTableNameWithPrefix(logicSQL, schemaName + ".", databaseType, databaseName)); + String result = replaceTableNameWithPrefix(logicSQL, schemaName + ".", databaseType, databaseName); + if (result.toUpperCase().startsWith("CREATE TABLE")) { + result = result.replaceFirst("CREATE TABLE", "CREATE TABLE IF NOT EXISTS"); + } + return Optional.of(result); Review Comment: 1, `result.toUpperCase().startsWith` and `result.replaceFirst` might have different String value, it's not consistent; 2, Will `IF NOT EXISTS` be added in underlying SQL generator? If true, then result might include duplicated `IF NOT EXISTS` ########## shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java: ########## @@ -269,7 +270,15 @@ protected void createScalingRule() { } protected void createSchema(final String schemaName) { - executeWithLog(String.format("CREATE SCHEMA %s", schemaName)); + try { + executeWithLog(String.format("CREATE SCHEMA %s", schemaName)); + } catch (final BadSqlGrammarException ex) { + if (ex.getMessage().contains("schema \"test\" already exists")) { + log.info("schema {} already exists.", schemaName); + } else { Review Comment: It's not good enough to check hard-coded error message. Is there another way to check whether schema is existing or not? e.g. from database metadata? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
