Example

This example takes the topic and adds it to the topicName field of the value.

Configuration
{
  "transforms" : "topicNameToField",
  "transforms.topicNameToField.type" : "com.github.jcustenborder.kafka.connect.transform.common.TopicNameToField$Value",
  "transforms.topicNameToField.field" : "topicName"
}
Input
{
  "topic" : "testing",
  "kafkaPartition" : 1,
  "keySchema" : {
    "type" : "STRING",
    "isOptional" : false
  },
  "key" : "foo",
  "valueSchema" : {
    "type" : "STRUCT",
    "isOptional" : false,
    "fieldSchemas" : {
      "test" : {
        "type" : "STRING",
        "isOptional" : false
      }
    }
  },
  "value" : {
    "schema" : {
      "type" : "STRUCT",
      "isOptional" : false,
      "fieldSchemas" : {
        "test" : {
          "type" : "STRING",
          "isOptional" : false
        }
      }
    },
    "fieldValues" : [ {
      "name" : "test",
      "schema" : {
        "type" : "STRING",
        "isOptional" : false
      },
      "storage" : "test"
    } ]
  },
  "timestamp" : 1530286549123,
  "timestampType" : "CREATE_TIME",
  "offset" : 91283741,
  "headers" : [ ]
}

Change(s) in the output are emphasized if delta(s) are detected.

Output
{
  "topic" : "testing",
  "kafkaPartition" : 1,
  "keySchema" : {
    "type" : "STRING",
    "isOptional" : false
  },
  "key" : "foo",
  "valueSchema" : {
    "type" : "STRUCT",
    "isOptional" : false,
    "fieldSchemas" : {
      "test" : {
        "type" : "STRING",
        "isOptional" : false
      },
      "topicName" : {
        "doc" : "Topic name",
        "type" : "STRING",
        "isOptional" : false
      }
    }
  },
  "value" : {
    "schema" : {
      "type" : "STRUCT",
      "isOptional" : false,
      "fieldSchemas" : {
        "test" : {
          "type" : "STRING",
          "isOptional" : false
        },
        "topicName" : {
          "doc" : "Topic name",
          "type" : "STRING",
          "isOptional" : false
        }
      }
    },
    "fieldValues" : [ {
      "name" : "test",
      "schema" : {
        "type" : "STRING",
        "isOptional" : false
      },
      "storage" : "test"
    }, {
      "name" : "topicName",
      "schema" : {
        "doc" : "Topic name",
        "type" : "STRING",
        "isOptional" : false
      },
      "storage" : "testing"
    } ]
  },
  "timestamp" : 1530286549123,
  "timestampType" : "CREATE_TIME",
  "offset" : 91283741,
  "headers" : [ ]
}