Skip to content
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

Enable BigQuery CDC configuration for Python BigQuery sink #32529

Merged
merged 40 commits into from
Oct 15, 2024

Conversation

prodriguezdefino
Copy link
Contributor

@prodriguezdefino prodriguezdefino commented Sep 21, 2024

Enables the configuration of CDC writes into a BigQuery table by setting the primary key columns to be used in the row mutations. This change adds the configuration of CDC usage for the BigQueryStorageWriteApiSchemaTransformProvider.

By setting configuration.setUseCDCWritesWithPrimaryKey(List.of("col1", "col2")) on the provider's config, the transform creation will create a BigQuery.Write<Row> transform that will configure the right row mutation information by checking for a Row schema like:

{
  row_mutation_info:{
    mutation_type: "..."              // can be UPSERT or DELETE
    change_sequence_number: "..."     // used for custom insert ordering
  }
  record:{...}                        // actual data to be inserted
}

The implementation also enables the possibility of setting a dynamic destination alongside with CDC usage by using this Row schema:

{
  row_mutation_info:{
    mutation_type: "..."              // can be UPSERT or DELETE
    change_sequence_number: "..."     // used for custom insert ordering
  }
  destination: "..."                  // destination table for the data
  record:{...}                        // actual data to be inserted
}

Note: In case of using dynamic destination and CDC is only supported when all the destination share the same primary key columns.


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.

@prodriguezdefino
Copy link
Contributor Author

fixes #32527

@prodriguezdefino
Copy link
Contributor Author

I have a question @ahmedabu98, how to make sure the xlang tests for BQ have run?

This branch test output for the test looks pretty similar to those that ran in master the last time, but in both cases it seems that the BQ StorageWrite transform is not being registered.

Am I looking at the right place or are the IT for xlang run in some other different task?

@ahmedabu98
Copy link
Contributor

The test you are referencing is to generate wrappers for external transforms (unrelated here since this wrapper is handwritten).

The workflows testing GCP xlang IOs are in beam_PostCommit_Python_Xlang_Gcp_Dataflow and beam_PostCommit_Python_Xlang_Gcp_Direct. These are post commits so to trigger them you just need to modify their respective target files and push it to this branch:

…plemented table constraint support on the bigquery fake dataset services
@prodriguezdefino prodriguezdefino marked this pull request as ready for review September 24, 2024 05:52
@github-actions github-actions bot added build and removed build labels Oct 2, 2024
@github-actions github-actions bot added build and removed build labels Oct 2, 2024
@github-actions github-actions bot added build and removed build labels Oct 3, 2024
@github-actions github-actions bot added build and removed build labels Oct 3, 2024
@prodriguezdefino
Copy link
Contributor Author

Run Java_GCP_IO_Direct PreCommit

@github-actions github-actions bot added build and removed build labels Oct 4, 2024
@prodriguezdefino
Copy link
Contributor Author

Run Java_Examples_Dataflow PreCommit

@ahmedabu98
Copy link
Contributor

FYI @prodriguezdefino we migrated our tests from Jenkins to Github Actions, so tests aren't triggered by comments anymore. I re-ran the Java examples workflow from my side

Check out https://github.com/apache/beam/tree/master/.github/workflows#readme for more info

@prodriguezdefino
Copy link
Contributor Author

@ahmedabu98 thanks for launching the test run.

I think I covered the previous comments on the PR, do you think is ready or it needs more work?

Copy link
Contributor

@ahmedabu98 ahmedabu98 left a comment

Choose a reason for hiding this comment

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

It's almost there, just a few more things.
Sorry for all the back and forth 😅

…n tests, included the CDC configurations into the existing RowDynamicDestinations object, improved error message for mutation information schema checks.
Copy link
Contributor

@ahmedabu98 ahmedabu98 left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks for your patience and sticking this one out @prodriguezdefino, looking forward to users trying this out :)

@ahmedabu98
Copy link
Contributor

Before I merge, can we add a line to CHANGES.md calling out this new feature? (make sure to mention it's specifically for storage write api's at-least-once mode)

@prodriguezdefino
Copy link
Contributor Author

Before I merge, can we add a line to CHANGES.md calling out this new feature? (make sure to mention it's specifically for storage write api's at-least-once mode)

Added the changes here: #32788 (less tests that need to pass for the change).

Thanks for the review!

@ahmedabu98
Copy link
Contributor

SGTM, merging

@ahmedabu98 ahmedabu98 merged commit e52868c into apache:master Oct 15, 2024
108 checks passed
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.

2 participants