提交 d8a7ea6b 编写于 作者: S SilverNarcissus 提交者: Jialin Qiao

[IOTDB-240] fix unknown time series in where clause (#443)

* fix querying non-existing paths in where clause"
上级 da658d7b
......@@ -512,8 +512,7 @@ public class MTree implements Serializable {
MNode cur = getRoot();
for (int i = 1; i < nodes.length; i++) {
if (!cur.hasChild(nodes[i])) {
throw new PathErrorException(
String.format(NO_CHILD_ERROR,cur.getName(),nodes[i]));
throw new PathErrorException("Path: \"" + path + "\" doesn't correspond to any known time series");
}
cur = cur.getChild(nodes[i]);
}
......
......@@ -276,6 +276,9 @@ public class ConcatPathOptimizer implements ILogicalOptimizer {
for (Path path : paths) {
List<String> all;
all = executor.getAllPaths(path.getFullPath());
if(all.isEmpty()){
throw new LogicalOptimizeException("Path: \"" + path + "\" doesn't correspond to any known time series");
}
for (String subPath : all) {
if (!pathMap.containsKey(subPath)) {
pathMap.put(subPath, 1);
......@@ -299,7 +302,7 @@ public class ConcatPathOptimizer implements ILogicalOptimizer {
try {
List<String> actualPaths = executor.getAllPaths(paths.get(i).getFullPath());
if(actualPaths.isEmpty()){
throw new LogicalOptimizeException("Path: \"" + paths.get(i) + "\" not corresponding any known time series");
throw new LogicalOptimizeException("Path: \"" + paths.get(i) + "\" doesn't correspond to any known time series");
}
for (String actualPath : actualPaths) {
retPaths.add(new Path(actualPath));
......
......@@ -334,4 +334,46 @@ public class IoTDBMultiSeriesIT {
fail(e.getMessage());
}
}
@Test
public void selectUnknownTimeSeries() throws ClassNotFoundException {
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.execute("select s10 from root.vehicle.d0");
fail("not throw exception when select unknown time series");
} catch (SQLException e) {
assertEquals("Execute statement error: Path: \"root.vehicle.d0.s10\" doesn't correspond to any known time series", e.getMessage());
}
}
@Test
public void selectWhereUnknownTimeSeries() throws ClassNotFoundException {
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.execute("select s1 from root.vehicle.d0 where s0 < 111 and s10 < 111");
fail("not throw exception when unknown time series in where clause");
} catch (SQLException e) {
assertEquals("Execute statement error: Path: \"root.vehicle.d0.s10\" doesn't correspond to any known time series", e.getMessage());
}
}
@Test
public void selectWhereUnknownTimeSeriesFromRoot() throws ClassNotFoundException {
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.execute("select s1 from root.vehicle.d0 where root.vehicle.d0.s0 < 111 and root.vehicle.d0.s10 < 111");
fail("not throw exception when unknown time series in where clause");
} catch (SQLException e) {
assertEquals("Execute statement error: Path: \"root.vehicle.d0.s10\" doesn't correspond to any known time series", e.getMessage());
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册