-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[Python][Java] Add support for record headers in WriteToKafka (Fixes #27033) #37458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…y configuration Users need to configure bounded backoff to prevent infinite retry loops. Making withBackOffSupplier public allows users to set FluentBackoff.DEFAULT.withMaxRetries(n) and control retry behavior. Changes: - Changed withBackOffSupplier() visibility from package-private to public - Added comprehensive integration test with zero-delay BoundedBackOff - Test verifies: responses empty, 1 failure emitted, call count = maxRetries+1 The test uses a serializable BoundedBackOff class with assertions on both PAssert (pipeline outputs) and Metrics (retry counts) to ensure bounded retry behavior works correctly. Fixes apache#37198 Related to apache#37176 Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…pache#27033) 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` - Add test `testConstructKafkaWriteWithHeaders` in KafkaIOExternalTest When `with_headers=True`, input elements must be `beam.Row` with schema: - 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) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Summary of ChangesHello @PDGGK, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Apache Beam Python SDK's Kafka integration by adding native support for Kafka record headers. This feature allows users to attach metadata to their Kafka messages, providing greater flexibility and richer context for data processing workflows. The implementation involves a new cross-language transform in Java to handle the conversion of structured Beam Row elements into Kafka ProducerRecords with headers, alongside updates to the Python Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Assigning reviewers: R: @tvalentyn for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
- Wrap URN_WITH_HEADERS to fit 80 char limit - Add blank line before docstring list for Sphinx - Format if statement per yapf style
Summary
This PR adds support for writing Kafka record headers in the Python SDK by introducing a new cross-language transform.
Changes:
with_headersparameter toWriteToKafkathat acceptsbeam.Rowelements with key, value, and optional headers fieldsWriteWithHeadersclass that converts Row to ProducerRecord with headers supportbeam:transform:org.apache.beam:kafka_write_with_headers:v1testConstructKafkaWriteWithHeadersin KafkaIOExternalTestInput Schema
When
with_headers=True, input elements must bebeam.Rowwith: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
Test plan
testConstructKafkaWriteWithHeaderspassesRelated Issues
Fixes #27033
🤖 Generated with Claude Code