You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/08/02 03:18:28 UTC
[GitHub] [iotdb] ijihang commented on a change in pull request #3649: [IOTDB-1536]Support fuzzy query
ijihang commented on a change in pull request #3649:
URL: https://github.com/apache/iotdb/pull/3649#discussion_r680628173
##########
File path: server/src/test/java/org/apache/iotdb/db/integration/IoTDBQueryDemoIT.java
##########
@@ -483,4 +483,68 @@ public void InTest() throws ClassNotFoundException {
}
return actualIndexToExpectedIndexList;
}
+
+ @Test
+ public void LikeTest() throws ClassNotFoundException {
+ String[] retArray =
+ new String[] {
+ "1509465600000,v2,true,", "1509465660000,v2,true,", "1509465720000,v1,false,",
+ };
+
+ Class.forName(Config.JDBC_DRIVER_NAME);
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+
+ statement.setFetchSize(4);
+ Assert.assertEquals(4, statement.getFetchSize());
+ // Matches a string consisting of one lowercase letter and one digit. such as: "v1","v2"
+ boolean hasResultSet =
+ statement.execute(
+ "select hardware,status from root.ln.wf02.wt02 where hardware like '^[a-z][0-9]$' and time < 1509465780000");
+ Assert.assertTrue(hasResultSet);
+ try (ResultSet resultSet = statement.getResultSet()) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ List<Integer> actualIndexToExpectedIndexList =
+ checkHeader(
+ resultSetMetaData,
+ "Time," + "root.ln.wf02.wt02.hardware,root.ln.wf02.wt02.status,",
+ new int[] {
+ Types.TIMESTAMP, Types.VARCHAR, Types.BOOLEAN,
+ });
+
+ int cnt = 0;
+ while (resultSet.next()) {
+ String[] expectedStrings = retArray[cnt].split(",");
+ StringBuilder expectedBuilder = new StringBuilder();
+ StringBuilder actualBuilder = new StringBuilder();
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ actualBuilder.append(resultSet.getString(i)).append(",");
+ expectedBuilder
+ .append(expectedStrings[actualIndexToExpectedIndexList.get(i - 1)])
+ .append(",");
+ }
+ Assert.assertEquals(expectedBuilder.toString(), actualBuilder.toString());
+ cnt++;
+ }
+ Assert.assertEquals(3, cnt);
+ }
+
+ hasResultSet =
+ statement.execute(
+ "select hardware,status from root.ln.wf02.wt02 where hardware like 'v*' ");
Review comment:
New commit added test
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org