+
Skip to content

feat(bigtable): Add samples for deletes using streaming and batching #5335

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

Merged
merged 4 commits into from
Jun 11, 2025

Conversation

bhshkh
Copy link
Contributor

@bhshkh bhshkh commented Jun 5, 2025

Description

Fixes b/417638724
This sample will show up in https://cloud.google.com/bigtable/docs/delete-data#delete-stream-batch

Checklist

  • I have followed Contributing Guidelines from CONTRIBUTING.MD
  • Tests pass: go test -v ./.. (see Testing)
  • Code formatted: gofmt (see Formatting)
  • Vetting pass: go vet (see Formatting)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@bhshkh bhshkh requested review from a team as code owners June 5, 2025 03:23
Copy link

snippet-bot bot commented Jun 5, 2025

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added api: bigtable Issues related to the Bigtable API. samples Issues that are directly related to samples. labels Jun 5, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @bhshkh, 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!

Summary of Changes

Hello! Gemini here, providing a summary of this pull request. This PR, authored by bhshkh, introduces a new sample for Google Cloud Bigtable in Go. The primary goal, as indicated by the title and description (fixing b/417638724), is to demonstrate a pattern for deleting data in Bigtable by first streaming through rows to identify candidates for deletion and then applying those deletions efficiently in a batch operation. This involves adding both the sample code itself and a corresponding integration test to verify its functionality.

Highlights

  • New Bigtable Sample: Adds a new Go sample demonstrating a specific Bigtable deletion pattern.
  • Streaming Reads + Batch Deletes: The sample shows how to read rows using streaming (tbl.ReadRows) and collect mutations, then apply those mutations in a single bulk request (tbl.ApplyBulk) for efficiency.
  • Integration Test Coverage: Includes a comprehensive integration test that sets up a temporary Bigtable table, populates it with test data, runs the sample function, and verifies that the intended cells were successfully deleted.

Changelog

Click here to see the changelog
  • bigtable/deletes/delete_streaming_batching.go
    • Added a new file containing the streamingAndBatching function.
    • Implements reading all rows from a specified table.
    • For each row, creates a mutation to delete the cell in column cell_plan:data_plan_01gb.
    • Collects row keys and mutations into slices.
    • Applies the collected mutations using tbl.ApplyBulk.
    • Includes error handling for client creation, reading rows, and applying bulk mutations.
  • bigtable/deletes/delete_streaming_batching_test.go
    • Added a new file containing the TestStreamingAndBatching integration test.
    • Sets up a temporary Bigtable table and column family for testing.
    • Writes test data to the table, including the cell targeted for deletion.
    • Calls the streamingAndBatching function with the test table.
    • Verifies the function's output message.
    • Reads the test rows after the function runs to confirm the specific cell (cell_plan:data_plan_01gb) has been deleted.
Using Gemini Code Assist

The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and 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 to provide feedback.

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.


Data flows like a stream,
Batching deletes, a coded dream.
Bigtable's might,
Making data light,
Cleaning up, a joyful gleam.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new Go samples for deleting data from Bigtable using streaming reads and batched delete operations. The code is generally well-structured, and the accompanying test provides good coverage for the new functionality. I've identified a couple of areas for improvement, primarily related to package naming conventions and error reporting clarity, which I've detailed in the comments. Overall, this is a valuable addition to the samples.

Summary of Findings

  • Package Naming Inconsistency: The Go package for the new sample (writes) does not match its directory (deletes/). This should be aligned for better code organization and clarity (e.g., package deletes). This applies to both the sample file and its test file.
  • Incorrect Error Reporting for Bulk Operations: The error handling for tbl.ApplyBulk can inaccurately report errors. Specifically, it may return an error message indicating failures based on the total number of mutations rather than actual errors, and it might return an error even if all individual mutations succeeded.

Merge Readiness

The pull request introduces useful samples and is generally well-implemented. However, there are a couple of medium severity issues related to package naming and error reporting that I recommend addressing before merging. Addressing these points will improve the clarity and correctness of the samples. I am not authorized to approve pull requests, so please ensure further review and approval as per your team's process after making any changes.

@bhshkh bhshkh enabled auto-merge (squash) June 5, 2025 03:30
@telpirion telpirion self-assigned this Jun 5, 2025
@bhshkh bhshkh requested a review from telpirion June 5, 2025 22:17
Copy link
Collaborator

@telpirion telpirion left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you so much!

@bhshkh bhshkh merged commit d5b4868 into GoogleCloudPlatform:main Jun 11, 2025
9 checks passed
@bhshkh bhshkh deleted the feature/cbt-delete-streaming branch June 12, 2025 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the Bigtable API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载