PDGGK opened a new pull request, #37458:
URL: https://github.com/apache/beam/pull/37458

   ## Summary
   
   This PR adds support for writing Kafka record headers in the Python SDK by 
introducing a new cross-language transform.
   
   **Changes:**
   - **Python**: Add `with_headers` parameter to `WriteToKafka` that accepts 
`beam.Row` elements with key, value, and optional headers fields
   - **Java**: Add `WriteWithHeaders` class that converts Row to ProducerRecord 
with headers support
   - **Java**: Register new URN 
`beam:transform:org.apache.beam:kafka_write_with_headers:v1`
   - **Test**: Add `testConstructKafkaWriteWithHeaders` in KafkaIOExternalTest
   
   ## Input Schema
   
   When `with_headers=True`, input elements must be `beam.Row` with:
   - `key`: bytes (required)
   - `value`: bytes (required)  
   - `headers`: List[Row(key=str, value=bytes)] (optional)
   - `topic`: str (optional, per-record override)
   - `partition`: int (optional)
   - `timestamp`: long (optional)
   
   ## Example Usage
   
   ```python
   # Write with headers
   records = [
       beam.Row(
           key=b'k1', 
           value=b'v1', 
           headers=[beam.Row(key='h1', value=b'hv1')]
       )
   ]
   
   p | beam.Create(records) | WriteToKafka(
       producer_config={'bootstrap.servers': 'localhost:9092'},
       topic='my-topic',
       with_headers=True
   )
   ```
   
   ## Test plan
   
   - [x] Java compilation passes
   - [x] `testConstructKafkaWriteWithHeaders` passes
   - [x] Code reviewed by Codex and Gemini
   
   ## Related Issues
   
   Fixes #27033
   
   ---
   🤖 Generated with [Claude Code](https://claude.ai/code)


-- 
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