Content-Length: 320321 | pFad | http://github.com/GoogleCloudPlatform/golang-samples/pull/5319

F2 fix(spanner): update sample to include adding split point with ExpireTime set by rahul2393 · Pull Request #5319 · GoogleCloudPlatform/golang-samples · GitHub
Skip to content

fix(spanner): update sample to include adding split point with ExpireTime set #5319

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 3 commits into from
May 19, 2025

Conversation

rahul2393
Copy link
Contributor

Description

Fixes #

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

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

@rahul2393 rahul2393 requested review from a team as code owners May 19, 2025 07:04
@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 May 19, 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 @rahul2393, 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 or gemini-code-assist here, providing a summary of this pull request.

This pull request updates the existing spanner_database_add_split_points.go sample. The primary goal is to enhance the sample by demonstrating how to add a split point with the ExpireTime field set. Previously, the sample only covered adding split points without specifying an expiration. This change introduces a new split point definition that includes setting the ExpireTime to 24 hours in the future, offering a more comprehensive example of the AddSplitPoints API functionality.

Highlights

  • Sample Enhancement: The spanner_database_add_split_points.go sample is updated to show a more complete use case.
  • Demonstrate ExpireTime: A new split point is added to specifically illustrate how to set the ExpireTime field.
  • Future Expiration: The sample now includes setting an expiration time for a split point to 24 hours from the current time.

Changelog

  • spanner/spanner_snippets/spanner/spanner_database_add_split_points.go
    • Added imports for the time package and google.golang.org/protobuf/types/known/timestamppb to handle time values and protobuf timestamps.
    • Created a new SplitPoints_Key object (splitTableKeyWithExpire) with the key value "30".
    • Defined a new SplitPoints object (splitForTableWithExpire) targeting the "Singers" table, using the new key and setting the ExpireTime to time.Now().Add(24 * time.Hour).
    • Included the newly created splitForTableWithExpire object in the SplitPoints slice passed to the AddSplitPointsRequest.
    • Added comments explaining the behavior and constraints of the ExpireTime field.
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 splits apart,
Expires after one day,
Sample shows the way.

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

The changes successfully update the sample to include adding a split point with the ExpireTime set, addressing the issue mentioned in the pull request description. The code is clear, follows the existing pattern of the sample, and correctly utilizes the necessary types and functions from the Spanner client library and protobufs. The addition of comments explaining the ExpireTime field is helpful.

Summary of Findings

  • Test coverage detail: The existing integration test TestAddSplitPointsSample asserts that the output contains "Added split points". While this confirms the function ran without error, it doesn't specifically verify that the split point with ExpireTime was included in the request or that the ExpireTime was set correctly. For a sample, this level of testing might be acceptable, but for production code, more specific assertions would be beneficial. This was not included as a review comment due to the severity settings.
  • Output message verbosity: The sample prints the entire response object using fmt.Fprintf(w, "Added split points %s", res). While this shows the full response, it might be overly verbose for a simple sample output. A more concise message confirming the action might be preferable. This was not included as a review comment due to the severity settings.

Merge Readiness

The code changes are well-implemented and directly address the stated objective. I did not find any critical, high, or medium severity issues in the modified code. The pull request appears ready to be merged. Please note that I am unable to directly approve the pull request; other reviewers should review and approve this code before merging.

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.

So nicely formatted and readable. Thank you!

@telpirion telpirion enabled auto-merge (squash) May 19, 2025 15:54
@telpirion telpirion self-assigned this May 19, 2025
@telpirion telpirion merged commit 398c51a into main May 19, 2025
12 checks passed
@telpirion telpirion deleted the update-sample-with-expire-time branch May 19, 2025 16:47
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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/GoogleCloudPlatform/golang-samples/pull/5319

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy