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 @@ -44,13 +44,27 @@ public class IoTDBPipeWriteBackSinkIT extends AbstractPipeDualManualIT {

@Test
public void testWriteBackSinkWithTargetDatabaseForTreeModel() throws Exception {
testWriteBackSinkWithTargetDatabaseForTreeModel("root.target.db");
}

@Test
public void testWriteBackSinkPreservesTreeModelTargetDatabaseCase() throws Exception {
testWriteBackSinkWithTargetDatabaseForTreeModel("TargetDB");
}

private void testWriteBackSinkWithTargetDatabaseForTreeModel(final String targetDatabase)
throws Exception {
final String qualifiedTargetDatabase =
targetDatabase.startsWith("root.") ? targetDatabase : "root." + targetDatabase;
TestUtils.executeNonQueries(
senderEnv,
Arrays.asList(
"create database root.source",
"create timeseries root.source.d1.s1 with datatype=INT32,encoding=PLAIN",
"create database root.target.db",
"create timeseries root.target.db.d1.s1 with datatype=INT32,encoding=PLAIN"),
"create database " + qualifiedTargetDatabase,
"create timeseries "
+ qualifiedTargetDatabase
+ ".d1.s1 with datatype=INT32,encoding=PLAIN"),
null);

try (final SyncConfigNodeIServiceClient client =
Expand All @@ -65,7 +79,7 @@ public void testWriteBackSinkWithTargetDatabaseForTreeModel() throws Exception {
sourceAttributes.put("user", "root");

sinkAttributes.put("sink", "write-back-sink");
sinkAttributes.put("sink.database", "root.target.db");
sinkAttributes.put("sink.database", targetDatabase);
sinkAttributes.put("user", "root");

final TSStatus status =
Expand All @@ -89,8 +103,8 @@ public void testWriteBackSinkWithTargetDatabaseForTreeModel() throws Exception {

TestUtils.assertDataEventuallyOnEnv(
senderEnv,
"select * from root.target.db.**",
"Time,root.target.db.d1.s1,",
"select * from " + qualifiedTargetDatabase + ".**",
"Time," + qualifiedTargetDatabase + ".d1.s1,",
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("1,1,", "2,2,"))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Locale;
import java.util.Objects;

import static org.apache.iotdb.commons.conf.IoTDBConstant.MAX_DATABASE_NAME_LENGTH;
Expand Down Expand Up @@ -113,9 +112,7 @@ private static String validateTargetDatabase(final String targetDatabase) {
try {
PathUtils.checkAndReturnSingleMeasurement(trimmedTargetDatabase);
return validateAndNormalizeTreeModelDatabaseName(
IoTDBConstant.PATH_ROOT
+ IoTDBConstant.PATH_SEPARATOR
+ trimmedTargetDatabase.toLowerCase(Locale.ENGLISH));
IoTDBConstant.PATH_ROOT + IoTDBConstant.PATH_SEPARATOR + trimmedTargetDatabase);
} catch (final Exception e) {
throw new PipeException(
String.format("The target database %s is invalid.", targetDatabase), e);
Expand Down
Loading