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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
hs_err_pid*
.okhttpcache
.idea
*.iml
target
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
import com.google.common.base.Strings;
import org.apache.kafka.common.config.ConfigDef;
import org.apache.kafka.connect.connector.ConnectRecord;
import org.apache.kafka.connect.data.Field;
import org.apache.kafka.connect.data.Schema;
import org.apache.kafka.connect.data.SchemaAndValue;
import org.apache.kafka.connect.data.SchemaBuilder;
import org.apache.kafka.connect.data.Struct;
import org.apache.kafka.connect.data.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -71,7 +67,7 @@ protected SchemaAndValue processStruct(R record, Schema inputSchema, Struct inpu
for (Field inputField : inputSchema.fields()) {
builder.field(inputField.name(), inputField.schema());
}
builder.field(this.config.innerFieldName, innerField.schema());
builder.field(this.config.outputFieldName, innerField.schema());
return builder.build();
});
final Struct outputStruct = new Struct(outputSchema);
Expand All @@ -80,7 +76,7 @@ protected SchemaAndValue processStruct(R record, Schema inputSchema, Struct inpu
outputStruct.put(inputField.name(), value);
}
final Object innerFieldValue = innerStruct.get(this.config.innerFieldName);
outputStruct.put(this.config.innerFieldName, innerFieldValue);
outputStruct.put(this.config.outputFieldName, innerFieldValue);

return new SchemaAndValue(outputSchema, outputStruct);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void test() {
ImmutableMap.of(
ExtractNestedFieldConfig.INNER_FIELD_NAME_CONF, "state",
ExtractNestedFieldConfig.OUTER_FIELD_NAME_CONF, "address",
ExtractNestedFieldConfig.OUTPUT_FIELD_NAME_CONF, "state"
ExtractNestedFieldConfig.OUTPUT_FIELD_NAME_CONF, "newstate"
)
);

Expand All @@ -57,7 +57,7 @@ public void test() {
.field("first_name", Schema.STRING_SCHEMA)
.field("last_name", Schema.STRING_SCHEMA)
.field("address", innerSchema)
.field("state", Schema.STRING_SCHEMA)
.field("newstate", Schema.STRING_SCHEMA)
.build();
final Struct innerStruct = new Struct(innerSchema)
.put("city", "Austin")
Expand All @@ -70,7 +70,7 @@ public void test() {
.put("first_name", "test")
.put("last_name", "developer")
.put("address", innerStruct)
.put("state", "tx");
.put("newstate", "tx");

final SinkRecord inputRecord = new SinkRecord(
"topic",
Expand Down