Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3677,6 +3677,8 @@ private DataNodeQueryMessages() {}
public static final String EXCEPTION_UDFNAME_IS_NULL_83E9039B = "udfName is null";
public static final String EXCEPTION_URISTRING_IS_NULL_E7458C6A = "uriString is null";
public static final String EXCEPTION_FILEPATH_IS_NULL_84CE8A66 = "filePath is null";
public static final String EXCEPTION_LOAD_TSFILE_PATH_CANNOT_BE_EMPTY_2B106181 =
"The LOAD TSFILE path cannot be empty.";
public static final String EXCEPTION_DETAILS_IS_NULL_8EDEEA03 = "details is null";
public static final String EXCEPTION_COLUMNCATEGORY_IS_NULL_0075924B = "columnCategory is null";
public static final String EXCEPTION_ARGUMENTNAME_IS_NULL_7F8F665F = "argumentName is null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4420,6 +4420,8 @@ private DataNodeQueryMessages() {}
public static final String EXCEPTION_UDFNAME_IS_NULL_83E9039B = "udfName 不能为空";
public static final String EXCEPTION_URISTRING_IS_NULL_E7458C6A = "uriString 不能为空";
public static final String EXCEPTION_FILEPATH_IS_NULL_84CE8A66 = "filePath 不能为空";
public static final String EXCEPTION_LOAD_TSFILE_PATH_CANNOT_BE_EMPTY_2B106181 =
"LOAD TSFILE 路径不能为空。";
public static final String EXCEPTION_DETAILS_IS_NULL_8EDEEA03 = "details 不能为空";
public static final String EXCEPTION_COLUMNCATEGORY_IS_NULL_0075924B = "columnCategory 不能为空";
public static final String EXCEPTION_ARGUMENTNAME_IS_NULL_7F8F665F = "argumentName 不能为空";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ private LoadTsFile(
initAttributes();

try {
LoadTsFileStatement.validateLoadTsFilePath(filePath);
this.tsFiles =
validateInternalDataDir
? LoadTsFileStatement.processTsFile(new File(filePath), validateSourcePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public static LoadTsFileStatement createForPipe(String filePath) throws FileNotF
private LoadTsFileStatement(
String filePath, boolean validateSourcePath, boolean validateInternalDataDir)
throws FileNotFoundException {
validateLoadTsFilePath(filePath);
this.file = new File(filePath).getAbsoluteFile();
this.databaseLevel = IoTDBDescriptor.getInstance().getConfig().getDefaultDatabaseLevel();
this.verifySchema = true;
Expand All @@ -111,6 +112,13 @@ private LoadTsFileStatement(
this.statementType = StatementType.MULTI_BATCH_INSERT;
}

public static void validateLoadTsFilePath(final String filePath) throws FileNotFoundException {
if (filePath == null || filePath.isEmpty()) {
throw new FileNotFoundException(
DataNodeQueryMessages.EXCEPTION_LOAD_TSFILE_PATH_CANNOT_BE_EMPTY_2B106181);
}
}

public static List<File> processTsFile(final File file) throws FileNotFoundException {
return processTsFile(file, true, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ public void testAnalyzeSingleTableFileShouldNotCountTimestampInPointCount() thro
Assert.assertEquals(2, schemaCache.getVerifiedDeviceCount());
}

@Test
public void testTableLoadEmptyPathIsRejected() {
try {
new LoadTsFile(null, "", Collections.emptyMap());
Assert.fail("Expected empty LOAD TSFILE path to be rejected.");
} catch (final RuntimeException e) {
Assert.assertTrue(e.getMessage().contains("The LOAD TSFILE path cannot be empty."));
}
}

@Test
public void testTableSchemaCacheShouldThrowMismatchWhenVerifyingDataType() throws Exception {
final LoadTsFileTableSchemaCache schemaCache = createTableSchemaCache(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.queryengine.plan.parser.StatementGenerator;

import org.junit.Assert;
import org.junit.Test;
Expand All @@ -29,6 +30,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.ZoneId;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Stream;
Expand Down Expand Up @@ -144,6 +146,16 @@ public void testLoadInternalTsFileIsRejectedWithoutLeakingPath() throws Exceptio
}
}

@Test
public void testTreeLoadEmptyPathIsRejected() {
try {
StatementGenerator.createStatement("LOAD TSFILE ''", ZoneId.systemDefault());
Assert.fail("Expected empty LOAD TSFILE path to be rejected.");
} catch (final RuntimeException e) {
Assert.assertTrue(e.getMessage().contains("The LOAD TSFILE path cannot be empty."));
}
}

@Test
public void testLoadPipeReceiverTsFileOutsideDataDirIsAllowed() throws Exception {
final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
Expand Down
Loading