Skip to content

Commit a70575f

Browse files
authored
Correct error messages when encountered IllegalPathException (#15559)
* Addresses an issue where the error log message is inaccurate when an IllegalPathException occurs. Addresses an issue where the error log message is inaccurate when an IllegalPathException occurs cause by a insert sql is executed. A create sql is added in order to validate if the exception message is legal when IllegalPathExeption occurs. * format code * Fix the issue it scripts can not be past.
1 parent 6b38b5d commit a70575f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSetConfigurationIT.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void testSetDefaultSGLevel() throws SQLException {
165165
statement.execute("INSERT INTO root.fail(timestamp, s1) VALUES (1, 1)");
166166
} catch (SQLException e) {
167167
assertEquals(
168-
"509: root.fail is not a legal path, because it is no longer than default sg level: 3",
168+
"509: An error occurred when executing getDeviceToDatabase():root.fail is not a legal path, because it is no longer than default sg level: 3",
169169
e.getMessage());
170170
}
171171

@@ -176,6 +176,7 @@ public void testSetDefaultSGLevel() throws SQLException {
176176
assertTrue(e.getMessage().contains("Illegal defaultStorageGroupLevel: -1, should >= 1"));
177177
}
178178

179+
// Failed updates will not change the files.
179180
// Failed updates will not change the files.
180181
assertFalse(
181182
checkConfigFileContains(
@@ -197,6 +198,15 @@ public void testSetDefaultSGLevel() throws SQLException {
197198
// the default value should take effect
198199
Assert.assertEquals("root.a", databases.getString(1));
199200
assertFalse(databases.next());
201+
202+
// create timeseries with an illegal path
203+
try {
204+
statement.execute("CREATE TIMESERIES root.db1.s3 WITH datatype=INT32");
205+
} catch (SQLException e) {
206+
assertEquals(
207+
"509: An error occurred when executing getDeviceToDatabase():root.db1 is not a legal path, because it is no longer than default sg level: 3",
208+
e.getMessage());
209+
}
200210
}
201211
}
202212
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,11 @@ private void getDatabaseCacheResult(
481481
throw new StatementAnalyzeException("Failed to get database Map");
482482
}
483483
}
484-
} catch (final TException | MetadataException | ClientManagerException e) {
484+
} catch (MetadataException e) {
485+
throw new IoTDBRuntimeException(
486+
"An error occurred when executing getDeviceToDatabase():" + e.getMessage(),
487+
e.getErrorCode());
488+
} catch (TException | ClientManagerException e) {
485489
throw new StatementAnalyzeException(
486490
"An error occurred when executing getDeviceToDatabase():" + e.getMessage(), e);
487491
}

0 commit comments

Comments
 (0)