mirror of https://github.com/apache/iotdb
[IOTDB-240] fix unknown time series in where clause (#443)
* fix querying non-existing paths in where clause"
This commit is contained in:
parent
da658d7b33
commit
d8a7ea6bc9
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue