Skip to content

Commit d5815a5

Browse files
luoluoyuyuJackieTien97
authored andcommitted
Async Load: Set the database name null when appropriate & Enable auto-creation of the database by reading the isAutoCreateSchemaEnabled flag from config (#15489)
(cherry picked from commit 8ff0120)
1 parent d070257 commit d5815a5

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,20 @@ private TSStatus loadTsFile(final Pair<String, Boolean> filePair, final IClientS
217217
throws FileNotFoundException {
218218
final LoadTsFileStatement statement = new LoadTsFileStatement(filePair.getLeft());
219219
final List<File> files = statement.getTsFiles();
220-
if (!files.isEmpty()) {
221-
final File parentFile = files.get(0).getParentFile();
222-
statement.setDatabase(parentFile == null ? "null" : parentFile.getName());
223-
}
220+
221+
// It should be noted here that the instructions in this code block do not need to use the
222+
// DataBase, so the DataBase is assigned a value of null. If the DataBase is used later, an
223+
// exception will be thrown.
224+
final File parentFile;
225+
statement.setDatabase(
226+
files.isEmpty() || (parentFile = files.get(0).getParentFile()) == null
227+
? null
228+
: parentFile.getName());
224229
statement.setDeleteAfterLoad(true);
225230
statement.setConvertOnTypeMismatch(true);
226231
statement.setVerifySchema(isVerify);
227-
statement.setAutoCreateDatabase(false);
232+
statement.setAutoCreateDatabase(
233+
IoTDBDescriptor.getInstance().getConfig().isAutoCreateSchemaEnabled());
228234
return executeStatement(
229235
filePair.getRight() ? new PipeEnrichedStatement(statement) : statement, session);
230236
}

0 commit comments

Comments
 (0)