Skip to content

Commit 4e967a8

Browse files
committed
Fixed unit tests and pom file for maven surefile plugin
1 parent 8d7e852 commit 4e967a8

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
<artifactId>maven-surefire-plugin</artifactId>
148148
<version>2.22.0</version>
149149
<configuration>
150+
<excludedGroups>IntegrationTest</excludedGroups>
150151
<excludes>
151152
<exclude>**/*IT.java</exclude>
152153
</excludes>

src/main/java/com/altinity/clickhouse/sink/connector/model/ClickHouseStruct.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import org.slf4j.Logger;
1010
import org.slf4j.LoggerFactory;
1111

12-
import java.util.ArrayList;
13-
import java.util.List;
14-
import java.util.Map;
12+
import java.util.*;
1513

1614
import static com.altinity.clickhouse.sink.connector.model.SinkRecordColumns.*;
1715

@@ -176,29 +174,34 @@ public void setAdditionalMetaData(Map<String, Object> convertedValue) {
176174
}
177175
Struct source = (Struct) convertedValue.get(SOURCE);
178176

177+
List<Field> fields = source.schema().fields();
178+
HashSet<String> fieldNames = new HashSet<String>();
179+
for(Field f: fields) {
180+
fieldNames.add(f.name());
181+
}
179182
try {
180-
if (source.get(TS_MS) != null && source.get(TS_MS) instanceof Long) {
183+
if (fieldNames.contains(TS_MS) && source.get(TS_MS) != null && source.get(TS_MS) instanceof Long) {
181184
this.setTs_ms((Long) source.get(TS_MS));
182185
}
183-
if (source.get(SNAPSHOT) != null && source.get(SNAPSHOT) instanceof String) {
186+
if (fieldNames.contains(SNAPSHOT) && source.get(SNAPSHOT) != null && source.get(SNAPSHOT) instanceof String) {
184187
this.setSnapshot(Boolean.parseBoolean((String) source.get(SNAPSHOT)));
185188
}
186-
if (source.get(SERVER_ID) != null && source.get(SERVER_ID) instanceof Long) {
189+
if (fieldNames.contains(SERVER_ID) && source.get(SERVER_ID) != null && source.get(SERVER_ID) instanceof Long) {
187190
this.setServerId((Long) source.get(SERVER_ID));
188191
}
189-
if (source.get(BINLOG_FILE) != null && source.get(BINLOG_FILE) instanceof String) {
192+
if (fieldNames.contains(BINLOG_FILE) && source.get(BINLOG_FILE) != null && source.get(BINLOG_FILE) instanceof String) {
190193
this.setFile((String) source.get(BINLOG_FILE));
191194
}
192-
if (source.get(BINLOG_POS) != null && source.get(BINLOG_POS) instanceof Long) {
195+
if (fieldNames.contains(BINLOG_POS) && source.get(BINLOG_POS) != null && source.get(BINLOG_POS) instanceof Long) {
193196
this.setPos((Long) source.get(BINLOG_POS));
194197
}
195-
if (source.get(ROW) != null && source.get(ROW) instanceof Integer) {
198+
if (fieldNames.contains(ROW) && source.get(ROW) != null && source.get(ROW) instanceof Integer) {
196199
this.setRow((Integer) source.get(ROW));
197200
}
198-
if (source.get(SERVER_THREAD) != null && source.get(SERVER_THREAD) instanceof Integer) {
201+
if (fieldNames.contains(SERVER_THREAD) && source.get(SERVER_THREAD) != null && source.get(SERVER_THREAD) instanceof Integer) {
199202
this.setThread((Integer) convertedValue.get(SERVER_THREAD));
200203
}
201-
if(source.get(GTID) != null && source.get(GTID) instanceof String) {
204+
if(fieldNames.contains(GTID) && source.get(GTID) != null && source.get(GTID) instanceof String) {
202205
String[] gtidArray = ((String) source.get(GTID)).split(":");
203206
if(gtidArray.length == 2) {
204207
this.setGtid(Integer.parseInt(gtidArray[1]));

0 commit comments

Comments
 (0)