tristaZero commented on a change in pull request #9019:
URL: https://github.com/apache/shardingsphere/pull/9019#discussion_r557041541
##########
File path:
shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
##########
@@ -385,7 +390,11 @@ protected Boolean getSaneResult(final SQLStatement
sqlStatement) {
};
return driverJDBCExecutor.execute(executionGroups, sqlStatement,
routeUnits, jdbcExecutorCallback);
}
-
+
+ private void isToCalcite(final boolean isToCalcite) {
Review comment:
Hi, we can not add `set` or `get` functions for tests. I guess you want
to make this property `true`. That way, please refer to the following steps,
- Add another single table to `config-calcite.yaml`
- Modify your test SQL as `select xx,xx from singleTable1, singleTable2
where singleTable1.xx=singleTable2 and xx`
- If necessary, you can add SQLS to prepare the Calcite UT in
`jdbc_data.sql` and `jdbc_init.sql`. It is straightforward to create tables to
do calcite tests, isn't it?
##########
File path:
shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/CalcitePrepareStatement.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.Before;
+import org.junit.Test;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public final class CalcitePrepareStatement extends
AbstractShardingSphereDataSourceForCalciteTest {
Review comment:
Hi `CalcitePrepareStatementTest` is a good name, isn't it?
##########
File path:
shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/config-calcite.yaml
##########
@@ -0,0 +1,22 @@
+#
+# 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
+ tables:
+ t_encrypt:
+ actualDataNodes: jdbc_0.t_encrypt
Review comment:
Hi, could add a new line below this line?
##########
File path:
shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/CalcitePrepareStatement.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.Before;
+import org.junit.Test;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public final class CalcitePrepareStatement extends
AbstractShardingSphereDataSourceForCalciteTest {
+
+ private static final String INSERT_SQL = "INSERT INTO t_encrypt (id,
cipher_pwd, plain_pwd) VALUES (?, ?, ?)";
+
+ private static final String SELECT_SQL_BY_ID = "SELECT id, cipher_pwd,
plain_pwd FROM t_encrypt WHERE id = ?";
+
+ @Before
+ public void init() throws SQLException {
+ try (PreparedStatement statement =
getShardingSphereDataSource().getConnection().prepareStatement(INSERT_SQL)) {
Review comment:
Hi, we can consider inserting some data in `jdbc_data.sql` which is
designed for initialization.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]