You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2021/01/18 09:59:03 UTC
[shardingsphere] branch master updated: Test CalciteExecutor doing
query in single table. (#9019)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 64a7a68 Test CalciteExecutor doing query in single table. (#9019)
64a7a68 is described below
commit 64a7a689f5d3aecbf1ff1f67c31c73f0e4e0ed39
Author: lmhmhl <lm...@163.com>
AuthorDate: Mon Jan 18 17:58:34 2021 +0800
Test CalciteExecutor doing query in single table. (#9019)
* test the CalciteLogicSchemeFactory.class
* test the CalciteExecutor.class
* Test the CalciteExecutor doing single table query.
* Test the CalciteExecutor doing single table query.
* Test the CalciteExecutor doing single table query.
* Test the CalciteExecutor doing single table query.
---
.../statement/ShardingSpherePreparedStatement.java | 4 +-
.../core/statement/ShardingSphereStatement.java | 4 +-
.../driver/common/base/AbstractSQLCalciteTest.java | 83 +++++++++++++++++++
...ractShardingSphereDataSourceForCalciteTest.java | 93 ++++++++++++++++++++++
.../statement/CalcitePrepareStatementTest.java | 53 ++++++++++++
.../jdbc/core/statement/CalciteStatementTest.java | 51 ++++++++++++
.../src/test/resources/calcite_data_0.sql | 21 +++++
.../src/test/resources/calcite_data_1.sql | 23 ++++++
.../src/test/resources/config-calcite.yaml | 21 +++++
.../src/test/resources/jdbc_init_calcite_0.sql | 18 +++++
.../src/test/resources/jdbc_init_calcite_1.sql | 18 +++++
11 files changed, 385 insertions(+), 4 deletions(-)
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index f083335..0a277f1 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -129,7 +129,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
@Getter(AccessLevel.PROTECTED)
private CalciteExecutor calciteExecutor;
-
+
public ShardingSpherePreparedStatement(final ShardingSphereConnection connection, final String sql) throws SQLException {
this(connection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, false);
}
@@ -402,7 +402,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
return executionContext.getSqlStatementContext() instanceof InsertStatementContext
? ((InsertStatementContext) executionContext.getSqlStatementContext()).getGeneratedKeyContext() : Optional.empty();
}
-
+
@Override
public ResultSet getGeneratedKeys() throws SQLException {
Optional<GeneratedKeyContext> generatedKey = findGeneratedKey(executionContext);
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index 2130188..75f9151 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -115,7 +115,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
@Getter(AccessLevel.PROTECTED)
private CalciteExecutor calciteExecutor;
-
+
public ShardingSphereStatement(final ShardingSphereConnection connection) {
this(connection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
@@ -385,7 +385,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
};
return driverJDBCExecutor.execute(executionGroups, sqlStatement, routeUnits, jdbcExecutorCallback);
}
-
+
private ExecutionContext createExecutionContext(final String sql) throws SQLException {
clearStatements();
LogicSQL logicSQL = createLogicSQL(sql);
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/common/base/AbstractSQLCalciteTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/common/base/AbstractSQLCalciteTest.java
new file mode 100644
index 0000000..d3062c9
--- /dev/null
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/common/base/AbstractSQLCalciteTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.driver.common.base;
+
+import org.apache.commons.dbcp2.BasicDataSource;
+import org.apache.shardingsphere.driver.common.env.DatabaseEnvironment;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
+import org.h2.tools.RunScript;
+import org.junit.BeforeClass;
+
+import javax.sql.DataSource;
+import java.io.InputStreamReader;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+
+public class AbstractSQLCalciteTest {
+
+ private static final Map<DatabaseType, Map<String, DataSource>> DATABASE_TYPE_MAP = new HashMap<>();
+
+ private static final String INIT_CALCITE_DATABASE_0 = "jdbc_init_calcite_0.sql";
+
+ private static final String INIT_CALCITE_DATABASE_1 = "jdbc_init_calcite_1.sql";
+
+ @BeforeClass
+ public static synchronized void initDataSource() {
+ createDataSources();
+ }
+
+ private static void createDataSources() {
+ createDataSources("jdbc_0", DatabaseTypeRegistry.getActualDatabaseType("H2"), INIT_CALCITE_DATABASE_0);
+ createDataSources("jdbc_1", DatabaseTypeRegistry.getActualDatabaseType("H2"), INIT_CALCITE_DATABASE_1);
+ }
+
+ private static void createDataSources(final String dbName, final DatabaseType databaseType, final String initSql) {
+ DATABASE_TYPE_MAP.computeIfAbsent(databaseType, key -> new LinkedHashMap<>()).put(dbName, buildDataSource(dbName, databaseType));
+ buildSchema(dbName, databaseType, initSql);
+ }
+
+ private static BasicDataSource buildDataSource(final String dbName, final DatabaseType databaseType) {
+ DatabaseEnvironment dbEnv = new DatabaseEnvironment(databaseType);
+ BasicDataSource result = new BasicDataSource();
+ result.setDriverClassName(dbEnv.getDriverClassName());
+ result.setUrl(dbEnv.getURL(dbName));
+ result.setUsername(dbEnv.getUsername());
+ result.setPassword(dbEnv.getPassword());
+ result.setMaxTotal(50);
+ return result;
+ }
+
+ private static void buildSchema(final String dbName, final DatabaseType databaseType, final String initSql) {
+ try {
+ Connection conn = DATABASE_TYPE_MAP.get(databaseType).get(dbName).getConnection();
+ RunScript.execute(conn, new InputStreamReader(Objects.requireNonNull(AbstractSQLTest.class.getClassLoader().getResourceAsStream(initSql))));
+ conn.close();
+ } catch (final SQLException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ protected static Map<DatabaseType, Map<String, DataSource>> getDatabaseTypeMap() {
+ return DATABASE_TYPE_MAP;
+ }
+}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/common/base/AbstractShardingSphereDataSourceForCalciteTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/common/base/AbstractShardingSphereDataSourceForCalciteTest.java
new file mode 100644
index 0000000..b7c6d36
--- /dev/null
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/common/base/AbstractShardingSphereDataSourceForCalciteTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.driver.common.base;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
+import org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
+import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
+import org.h2.tools.RunScript;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+import javax.sql.DataSource;
+import java.io.IOException;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+public class AbstractShardingSphereDataSourceForCalciteTest extends AbstractSQLCalciteTest {
+
+ private static ShardingSphereDataSource dataSource;
+
+ private static final List<String> CALCITE_DB_NAMES = Arrays.asList("jdbc_0", "jdbc_1");
+
+ private static final String CONFIG_CALCITE = "config-calcite.yaml";
+
+ @BeforeClass
+ public static void initCalciteDataSource() throws SQLException, IOException {
+ if (null != dataSource) {
+ return;
+ }
+ dataSource = (ShardingSphereDataSource) YamlShardingSphereDataSourceFactory.createDataSource(getDataSourceMap(), getFile(CONFIG_CALCITE));
+ }
+
+ private static Map<String, DataSource> getDataSourceMap() {
+ return Maps.filterKeys(getDatabaseTypeMap().values().iterator().next(), CALCITE_DB_NAMES::contains);
+ }
+
+ @Before
+ public void initTable() {
+ try {
+ ShardingSphereConnection conn = dataSource.getConnection();
+ Map<String, DataSource> dataSourceMap = conn.getDataSourceMap();
+ Connection database0 = dataSourceMap.get("jdbc_0").getConnection();
+ Connection database1 = dataSourceMap.get("jdbc_1").getConnection();
+ RunScript.execute(database0, new InputStreamReader(Objects.requireNonNull(AbstractSQLTest.class.getClassLoader().getResourceAsStream("calcite_data_0.sql"))));
+ RunScript.execute(database1, new InputStreamReader(Objects.requireNonNull(AbstractSQLTest.class.getClassLoader().getResourceAsStream("calcite_data_1.sql"))));
+ conn.close();
+ } catch (final SQLException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ private static File getFile(final String fileName) {
+ return new File(Preconditions.checkNotNull(
+ AbstractShardingSphereDataSourceForShardingTest.class.getClassLoader().getResource(fileName), "file resource `%s` must not be null.", fileName).getFile());
+ }
+
+ protected final ShardingSphereDataSource getShardingSphereDataSource() {
+ return dataSource;
+ }
+
+ @AfterClass
+ public static void clear() throws Exception {
+ if (null == dataSource) {
+ return;
+ }
+ dataSource.close();
+ dataSource = null;
+ }
+}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/CalcitePrepareStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/CalcitePrepareStatementTest.java
new file mode 100644
index 0000000..dd0d3a8
--- /dev/null
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/CalcitePrepareStatementTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.driver.jdbc.core.statement;
+
+import org.apache.shardingsphere.driver.common.base.AbstractShardingSphereDataSourceForCalciteTest;
+import org.junit.Test;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public final class CalcitePrepareStatementTest extends AbstractShardingSphereDataSourceForCalciteTest {
+
+ private static final String SELECT_SQL_BY_ID = "select o.*, i.* from t_order_calcite o, t_order_item_calcite i where o.order_id = ? and i.item_id = ?";
+
+ @Test
+ public void assertQueryWithCalciteInSingleTables() throws SQLException {
+ ShardingSpherePreparedStatement preparedStatement = (ShardingSpherePreparedStatement) getShardingSphereDataSource().getConnection().prepareStatement(SELECT_SQL_BY_ID);
+ preparedStatement.setInt(1, 1000);
+ preparedStatement.setInt(2, 100000);
+ ResultSet resultSet = preparedStatement.executeQuery();
+ assertNotNull(resultSet);
+ assertTrue(resultSet.next());
+ assertThat(resultSet.getInt(1), is(1000));
+ assertThat(resultSet.getInt(2), is(10));
+ assertThat(resultSet.getString(3), is("init"));
+ assertThat(resultSet.getInt(4), is(100000));
+ assertThat(resultSet.getInt(5), is(1000));
+ assertThat(resultSet.getInt(6), is(10));
+ assertThat(resultSet.getString(7), is("init"));
+ assertFalse(resultSet.next());
+ }
+}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/CalciteStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/CalciteStatementTest.java
new file mode 100644
index 0000000..0740d9b
--- /dev/null
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/CalciteStatementTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.driver.jdbc.core.statement;
+
+import org.apache.shardingsphere.driver.common.base.AbstractShardingSphereDataSourceForCalciteTest;
+import org.junit.Test;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public final class CalciteStatementTest extends AbstractShardingSphereDataSourceForCalciteTest {
+
+ private static final String SELECT_SQL_BY_ID = "select o.*, i.* from t_order_calcite o, t_order_item_calcite i where o.order_id = 1000 and i.item_id = 100000";
+
+ @Test
+ public void assertQueryWithCalciteInSingleTables() throws SQLException {
+ ShardingSphereStatement preparedStatement = (ShardingSphereStatement) getShardingSphereDataSource().getConnection().createStatement();
+ ResultSet resultSet = preparedStatement.executeQuery(SELECT_SQL_BY_ID);
+ assertNotNull(resultSet);
+ assertTrue(resultSet.next());
+ assertThat(resultSet.getInt(1), is(1000));
+ assertThat(resultSet.getInt(2), is(10));
+ assertThat(resultSet.getString(3), is("init"));
+ assertThat(resultSet.getInt(4), is(100000));
+ assertThat(resultSet.getInt(5), is(1000));
+ assertThat(resultSet.getInt(6), is(10));
+ assertThat(resultSet.getString(7), is("init"));
+ assertFalse(resultSet.next());
+ }
+}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/calcite_data_0.sql b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/calcite_data_0.sql
new file mode 100644
index 0000000..9549ac1
--- /dev/null
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/calcite_data_0.sql
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+DELETE FROM t_order_calcite;
+
+INSERT INTO t_order_calcite VALUES(1000, 10, 'init');
+INSERT INTO t_order_calcite VALUES(1001, 10, 'init');
\ No newline at end of file
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/calcite_data_1.sql b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/calcite_data_1.sql
new file mode 100644
index 0000000..11679b8
--- /dev/null
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/calcite_data_1.sql
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+DELETE FROM t_order_item_calcite;
+
+INSERT INTO t_order_item_calcite VALUES(100000, 1000, 10, 'init');
+INSERT INTO t_order_item_calcite VALUES(100001, 1000, 10, 'init');
+INSERT INTO t_order_item_calcite VALUES(100100, 1001, 10, 'init');
+INSERT INTO t_order_item_calcite VALUES(100101, 1001, 10, 'init');
\ No newline at end of file
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/config-calcite.yaml b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/config-calcite.yaml
new file mode 100644
index 0000000..ff32026
--- /dev/null
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/config-calcite.yaml
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+
+rules:
+ - !SHARDING
+ defaultTableStrategy:
+ none:
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/jdbc_init_calcite_0.sql b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/jdbc_init_calcite_0.sql
new file mode 100644
index 0000000..188ca15
--- /dev/null
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/jdbc_init_calcite_0.sql
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
+
+CREATE TABLE IF NOT EXISTS t_order_calcite (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/jdbc_init_calcite_1.sql b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/jdbc_init_calcite_1.sql
new file mode 100644
index 0000000..ec8d959
--- /dev/null
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/jdbc_init_calcite_1.sql
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
+
+CREATE TABLE IF NOT EXISTS t_order_item_calcite (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id));