Skip to content
Merged
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 @@ -129,4 +129,66 @@ public void testEnv() throws Exception {
}
}
}

@Test
public void testInsertNull() throws Exception {
DataNodeWrapper receiverDataNode = receiverEnv.getDataNodeWrapper(0);

String receiverIp = receiverDataNode.getIp();
int receiverPort = receiverDataNode.getPort();

try (SyncConfigNodeIServiceClient client =
(SyncConfigNodeIServiceClient) senderEnv.getLeaderConfigNodeConnection()) {
Map<String, String> extractorAttributes = new HashMap<>();
Map<String, String> processorAttributes = new HashMap<>();
Map<String, String> connectorAttributes = new HashMap<>();

connectorAttributes.put("connector", "iotdb-thrift-connector");
connectorAttributes.put("connector.ip", receiverIp);
connectorAttributes.put("connector.port", Integer.toString(receiverPort));

TSStatus status =
client.createPipe(
new TCreatePipeReq("testPipe", connectorAttributes)
.setExtractorAttributes(extractorAttributes)
.setProcessorAttributes(processorAttributes));

Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());

Assert.assertEquals(
TSStatusCode.SUCCESS_STATUS.getStatusCode(), client.startPipe("testPipe").getCode());

try (Connection connection = receiverEnv.getConnection();
Statement statement = connection.createStatement()) {
statement.execute("create aligned timeseries root.sg.d1(s0 float, s1 float)");
} catch (SQLException e) {
e.printStackTrace();
fail(e.getMessage());
}

try (Connection connection = senderEnv.getConnection();
Statement statement = connection.createStatement()) {
statement.execute("create aligned timeseries root.sg.d1(s0 float, s1 float)");
statement.execute("insert into root.sg.d1(time, s0, s1) values (3, null, 25.34)");
} catch (SQLException e) {
e.printStackTrace();
fail(e.getMessage());
}

try (Connection connection = receiverEnv.getConnection();
Statement statement = connection.createStatement()) {
await()
.atMost(600, TimeUnit.SECONDS)
.untilAsserted(
() ->
TestUtils.assertResultSetEqual(
statement.executeQuery("select * from root.**"),
"Time,root.sg.d1.s0,root.sg.d1.s1,",
Collections.singleton("3,null,25.34,")));
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

@SuppressWarnings("java:S106") // for console outputs
public class CommonUtils {
Expand Down Expand Up @@ -110,6 +111,9 @@ public static Object parseValue(TSDataType dataType, String value) throws QueryP
}

public static boolean checkCanCastType(TSDataType src, TSDataType dest) {
if (Objects.isNull(src)) {
return true;
}
switch (src) {
case INT32:
if (dest == TSDataType.INT64 || dest == TSDataType.FLOAT || dest == TSDataType.DOUBLE) {
Expand All @@ -128,6 +132,9 @@ public static boolean checkCanCastType(TSDataType src, TSDataType dest) {
}

public static Object castValue(TSDataType srcDataType, TSDataType destDataType, Object value) {
if (Objects.isNull(value)) {
return null;
}
switch (srcDataType) {
case INT32:
if (destDataType == TSDataType.INT64) {
Expand Down