Skip to content

feat(spanner): BatchWrite Sample#2191

Merged
bshaffer merged 1 commit intoGoogleCloudPlatform:mainfrom
surbhigarg92:spanner-batch-write-sample
Mar 18, 2026
Merged

feat(spanner): BatchWrite Sample#2191
bshaffer merged 1 commit intoGoogleCloudPlatform:mainfrom
surbhigarg92:spanner-batch-write-sample

Conversation

@surbhigarg92
Copy link
Contributor

No description provided.

@product-auto-label product-auto-label bot added api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples. labels Mar 13, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 introduces a new PHP sample for Google Cloud Spanner's BatchWrite API, providing a clear demonstration of how to efficiently insert data using mutation groups. It highlights the ability to define atomic operations within groups and handle responses for each group, offering a robust example for developers looking to optimize their Spanner write operations.

Highlights

  • New Spanner BatchWrite Sample: A new PHP sample has been added to demonstrate the usage of the Google Cloud Spanner BatchWrite API. This sample illustrates how to perform efficient, grouped data insertions.
  • BatchWrite Functionality: The sample showcases the creation of mutation groups, allowing for both atomic and non-atomic application of mutations, and processes the responses to confirm successful writes or identify errors.
  • Dedicated Test Case: A corresponding PHPUnit test file has been introduced to validate the functionality of the new BatchWrite sample, ensuring its correctness and providing a runnable example.
Changelog
  • spanner/src/batch_write.php
    • Added a new sample file for the Spanner BatchWrite API.
    • Implemented the batch_write function to demonstrate data insertion using atomic and non-atomic mutation groups.
    • Included logic to process and print the results of each mutation group's application.
  • spanner/test/spannerBatchWriteTest.php
    • Added a new PHPUnit test file for the batch_write sample.
    • Implemented testBatchWrite to execute the sample and assert that mutation groups were applied successfully.
Activity
  • No specific activity (comments, reviews, or progress updates) was provided in the context for this pull request.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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

  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 a new PHP sample for Cloud Spanner's BatchWrite functionality, which is a useful addition. The sample code clearly demonstrates how to group mutations and use the batchWriteAtLeastOnce method. The accompanying test file provides basic validation that the sample executes successfully. I have one suggestion to improve adherence to PHP coding standards in the test file.

* @retryAttempts 3
* @retryDelayMethod exponentialBackoff
*/
class spannerBatchWriteTest extends TestCase

Choose a reason for hiding this comment

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

medium

The class name spannerBatchWriteTest does not adhere to the PSR-1 coding standard, which requires class names to be in StudlyCaps (also known as PascalCase). For consistency and to follow best practices, please rename the class to SpannerBatchWriteTest.

class SpannerBatchWriteTest extends TestCase
References
  1. According to PSR-1: Basic Coding Standard, class names MUST be declared in StudlyCaps. (link)

@surbhigarg92 surbhigarg92 force-pushed the spanner-batch-write-sample branch from 9b543e8 to de6c9ca Compare March 18, 2026 06:23
@surbhigarg92 surbhigarg92 marked this pull request as ready for review March 18, 2026 06:24
@surbhigarg92 surbhigarg92 requested review from a team as code owners March 18, 2026 06:24
@snippet-bot
Copy link

snippet-bot bot commented Mar 18, 2026

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

@bshaffer bshaffer merged commit c8bdc7e into GoogleCloudPlatform:main Mar 18, 2026
4 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants