Skip to content

[KafkaIO] Add with_gcp_adc and num_partitions options to Kafka SchemaTransforms and YAML - #40181

Merged
Abacn merged 2 commits into
apache:masterfrom
Abacn:kafka-gmk-eou
Oct 5, 2026
Merged

Abacn merged 2 commits into
apache:masterfrom
Abacn:kafka-gmk-eou

Conversation

@Abacn

@Abacn Abacn commented Sep 18, 2026

Copy link
Copy Markdown
Contributor
  • Expose with_gcp_adc (withGcpAdc) in KafkaIO read/write SchemaTransform, Python xlang IO and YAML. This option is already present in Java KafkaIO but not exposed to xlang. It make Python and YAML user easier to use Google managed Kafka (GMK).

  • Add num_partitions in KafkaIO read SchemaTransform, Python xlang IO and YAML. This avoids the need to Kafka instance connection at pipeline submission time for Dataflow runner v1 (Streaming runner) if using SchemaTransform

Please add a meaningful description for your change here


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

…hemaTransforms and Beam YAML

- Expose `with_gcp_adc` (`withGcpAdc`) in KafkaIO read/write SchemaTransform, Python xlang IO and YAML

- Add `num_partitions` in KafkaIO read SchemaTransform, Python xlang IO and YAML. This avoids the need to Kafka instance connection at pipeline submission time for Dataflow runner v1 (Streaming runner) if using SchemaTransform
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @jrmccluskey for label python.
R: @chamikaramj for label java.
R: @sjvanrossum for label kafka.
R: @derrickaw for label yaml.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

+ " construction time.")
@SchemaFieldNumber("18")
@Nullable
public abstract Integer getNumPartitions();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases the partition set for a topic will match the range of integers from 0 to N, but users may arbitrarily retire individual partitions.
Examples:

  • Create a partition per entity with a non-sequential integer id (e.g., a partition per player in a game).
  • Retire a partition after the last usable offset is used to produce a record.

Replacing the number of partitions property with a topic partition list property would spare adding it later with more boilerplate to validate the different combinations of configuration properties.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true there is a risk number of partitions evolving won't get honored, but in fact it's the same limitation for a typical setup

  • on Dataflow streaming runner, it uses UnboundedSource, which resolves partitions at once, at initial split that happens at pipeline expansion time

  • on Dataflow portable runner, it uses SDF implementation. Initial split happens at pipeline execution time, but after that the partitions to consume is still fixed

There is an .withDynamicRead(...) option that support dynamic partitions, led to SDK implementation and requires Dataflow runner v2.

One of the motivation of exposing this option is to be able to use KafkaIO via SchemaTransform to connect to a GMK on Dataflow Streaming runner, therefore .withDynamicRead(...) isn't available here

+ " authenticating with a Google Managed Kafka cluster.")
@SchemaFieldNumber("17")
@Nullable
public abstract Boolean getWithGcpAdc();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This doesn't match the name used to configure the transform. Application default credentials is annoyingly long to spell so I'm not opposed to ADC, but I'd consider keeping it the same for consistency and clarity to users who might be unfamiliar with the acronym.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understand. Since this is mostly a ease-of-use change (users can current set GCP configs themselves by adding all needed configurations to config) a simple name is preferred

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@Abacn

Abacn commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@sjvanrossum friendly pin PTAL thanks!

@Abacn

Abacn commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merging for now

@Abacn
Abacn merged commit e2c9256 into apache:master Oct 5, 2026
112 of 113 checks passed
@Abacn
Abacn deleted the kafka-gmk-eou branch October 5, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants