wilmerdooley opened a new pull request, #22560:
URL: https://github.com/apache/kafka/pull/22560

   Delete this text and replace it with a detailed description of your change. 
The
   PR title and body will become the squashed commit message.
   
   If you would like to tag individuals, add some commentary, upload images, or
   include other supplemental information that should not be part of the 
eventual
   commit message, please use a separate comment.
   
   If applicable, please include a summary of the testing strategy (including
   rationale) for the proposed change. Unit and/or integration tests are 
expected
   for any behavior change and system tests should be considered for larger
   changes.
   
   This PR adds a new `value.type` configuration option to the `InsertHeader` 
SMT in 
`connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertHeader.java`.
 The option lets users specify the Connect `Schema` type for the literal value 
being inserted as a header, supporting `int8`, `int16`, `int32`, `int64`, 
`float32`, `float64`, `boolean`, `string`, and `bytes`. When `value.type` is 
omitted, the existing behavior of using `Values.parseString` is preserved, so 
the change is backward compatible.
   
   This addresses the underlying need behind KAFKA-10428 by allowing 
`InsertHeader` to produce schemas other than `Schema.STRING_SCHEMA` (most 
notably `Schema.BYTES_SCHEMA`), which is required for a `ByteArray` 
`header.converter`. Invalid `value.type` values are rejected at configure time 
with a `ConfigException`.
   
   ### Testing strategy
   
   Unit tests in 
`connect/transforms/src/test/java/org/apache/kafka/connect/transforms/InsertHeaderTest.java`
 cover the new behavior. `insertionWithExplicitTypes` exercises each supported 
type end to end through `apply`, asserting that the produced header carries the 
expected `Schema` and the expected value (with `assertArrayEquals` for the 
`bytes` case). A separate `configRejectsInvalidValueType` test verifies that an 
unknown type is rejected with `ConfigException`. The existing tests continue to 
pass because the default path (no `value.type` set) is unchanged.
   
   JIRA: https://issues.apache.org/jira/browse/KAFKA-19465


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to