sakshammalik260-cse opened a new pull request, #41880:
URL: https://github.com/apache/beam/pull/41880
## Summary
Closes #41863.
Adds an optional `withMetadataProjectId()` configuration method to
`SpannerIO.ReadChangeStream`, allowing change-stream metadata to be stored in a
Google Cloud Spanner database in a different project from the source database.
## Problem
Currently, the metadata configuration always inherits the source database's
project ID. Users managing databases across multiple GCP projects cannot
configure a centralized metadata database in a separate project.
## Solution
- Introduces `withMetadataProjectId(String)` through the existing immutable
AutoValue builder.
- Preserves the existing `MetadataSpannerConfigFactory` configuration policy.
- Applies the optional project override before metadata dialect detection
and DAO construction.
- Preserves credential handling, retry settings, and database-role isolation.
- Defaults to the source project when the metadata project is omitted.
- Maintains backward compatibility with existing pipelines.
No new production dependencies, additional network requests, or per-record
processing are introduced.
## Usage
```java
SpannerIO.readChangeStream()
.withProjectId("source-project")
.withInstanceId("source-instance")
.withDatabaseId("source-database")
.withMetadataProjectId("metadata-project")
.withMetadataInstance("metadata-instance")
.withMetadataDatabase("metadata-database");
```
## Testing and Validation
**84 targeted local unit tests passed with zero failures or skips.**
Regression coverage includes:
- Default, explicit, and cross-project metadata selection.
- Source and metadata configuration isolation.
- Fluent setter ordering and immutability.
- Metadata dialect detection and DAO routing.
- Worker-side configuration serialization.
- Project-specific database and administration client isolation.
- Credential, retry policy, and database-role preservation.
- Existing metadata configuration validation.
Controlled mutation testing confirmed that the regression tests detect
swapped dialect configurations, missing project overrides, and incorrectly
delayed project overrides.
The following quality checks passed:
- Java compilation and static analysis.
- Spotless.
- Checkstyle.
- Changelog validation.
- Apache RAT.
- `git diff --check`.
Live cross-project Spanner and IAM integration testing was not performed.
--
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]