Skip to content

Conversation

@alkatrivedi
Copy link
Contributor

@alkatrivedi alkatrivedi commented Dec 10, 2025

This PR is to add support for type UUID.

@alkatrivedi alkatrivedi requested review from a team as code owners December 10, 2025 10:34
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/nodejs-spanner API. labels Dec 10, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @alkatrivedi, 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 significantly enhances the Spanner client library by adding full support for the UUID data type. It integrates UUID handling into the core codec, updates parameter binding mechanisms, and includes thorough testing to ensure reliability and correctness across different Spanner dialects. This feature allows developers to work with UUIDs natively within their applications when interacting with Spanner databases.

Highlights

  • UUID Type Support: Introduced comprehensive support for the UUID data type across the Spanner client library, enabling proper handling of UUID values in both Google Standard SQL and PostgreSQL dialects.
  • Codec Enhancements: Updated the internal codec to correctly identify, encode, and decode UUID values, ensuring seamless conversion between application data and Spanner's UUID type.
  • Parameter Binding Logic: Refined the parameter encoding logic to ensure that type objects are only created for explicitly defined types or for types that are not TYPE_CODE_UNSPECIFIED, improving type inference and handling.
  • Extensive Testing: Added a suite of unit and system tests to validate the new UUID functionality, covering insertion, querying, and parameter binding for both single UUIDs and arrays of UUIDs in various scenarios.
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 support for the UUID data type in Spanner. The changes span across the codec for type handling, transaction logic for parameter encoding, and comprehensive additions to both unit and system tests. The approach for type inference is to let Spanner infer the type for UUID-like strings, which provides flexibility. The new tests are well-written and cover various scenarios. I've identified a couple of minor issues in the system tests where assertions for field counts were not updated, and a small inefficiency in the transaction processing logic. After addressing these points, the PR should be ready for merging.

Comment on lines +4255 to +4254
assert.strictEqual(metadata.rowType!.fields![2].name, 'UUID');
assert.strictEqual(metadata.rowType!.fields![3].name, 'Float32');
assert.strictEqual(metadata.rowType!.fields![4].name, 'Float');
assert.strictEqual(metadata.rowType!.fields![5].name, 'Int');
assert.strictEqual(metadata.rowType!.fields![6].name, 'Info');
assert.strictEqual(metadata.rowType!.fields![7].name, 'Created');
assert.strictEqual(metadata.rowType!.fields![8].name, 'DOB');
assert.strictEqual(metadata.rowType!.fields![9].name, 'Accents');
assert.strictEqual(metadata.rowType!.fields![10].name, 'PhoneNumbers');
assert.strictEqual(metadata.rowType!.fields![11].name, 'HasGear');

Choose a reason for hiding this comment

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

high

While you've correctly updated the assertions for the field names, the assertion for the total number of fields on line 4252 is now incorrect. With the addition of the UUID column, the total number of fields is 12, but the test still asserts 11. Please update that line as well:

assert.strictEqual(metadata.rowType!.fields!.length, 12);

Comment on lines 4287 to 4285
assert.strictEqual(metadata.rowType!.fields![2].name, 'UUID');
assert.strictEqual(metadata.rowType!.fields![3].name, 'Float32');
assert.strictEqual(metadata.rowType!.fields![4].name, 'Float');
assert.strictEqual(metadata.rowType!.fields![5].name, 'Int');
assert.strictEqual(metadata.rowType!.fields![6].name, 'Info');
assert.strictEqual(metadata.rowType!.fields![7].name, 'Created');
assert.strictEqual(metadata.rowType!.fields![8].name, 'HasGear');

Choose a reason for hiding this comment

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

high

Similar to the previous comment, the assertion for the total number of fields on line 4284 is now incorrect. With the addition of the UUID column, the total number of fields is 9, but the test still asserts 8. Please update that line as well:

assert.strictEqual(metadata.rowType!.fields!.length, 9);

Comment on lines 1731 to 1746
const typeObject = codec.createTypeObject(type);
if (
(type.child &&
typeObject.code === 'ARRAY' &&
typeObject.arrayElementType?.code !== 'TYPE_CODE_UNSPECIFIED') ||
(!type.child && typeObject.code !== 'TYPE_CODE_UNSPECIFIED')
) {
paramTypes[param] = codec.createTypeObject(type);
}

Choose a reason for hiding this comment

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

medium

The codec.createTypeObject(type) function is called twice here, once to create typeObject for the if condition and then again inside the if block. This is inefficient. You can reuse the typeObject that was already created.

Suggested change
const typeObject = codec.createTypeObject(type);
if (
(type.child &&
typeObject.code === 'ARRAY' &&
typeObject.arrayElementType?.code !== 'TYPE_CODE_UNSPECIFIED') ||
(!type.child && typeObject.code !== 'TYPE_CODE_UNSPECIFIED')
) {
paramTypes[param] = codec.createTypeObject(type);
}
const typeObject = codec.createTypeObject(type);
if (
(type.child &&
typeObject.code === 'ARRAY' &&
typeObject.arrayElementType?.code !== 'TYPE_CODE_UNSPECIFIED') ||
(!type.child && typeObject.code !== 'TYPE_CODE_UNSPECIFIED')
) {
paramTypes[param] = typeObject;
}

@alkatrivedi alkatrivedi force-pushed the uuid-type-support branch 2 times, most recently from 66a939f to 2708bba Compare December 10, 2025 11:16
@alkatrivedi alkatrivedi marked this pull request as draft December 10, 2025 11:23
@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • .github/workflows/ci.yaml - .github/workflows/ci.yaml (GitHub Actions) should be updated in synthtool

@alkatrivedi alkatrivedi force-pushed the uuid-type-support branch 6 times, most recently from 2c56455 to ed0352a Compare December 16, 2025 10:24
@alkatrivedi alkatrivedi added the owlbot:run Add this label to trigger the Owlbot post processor. label Dec 16, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Dec 16, 2025
@alkatrivedi alkatrivedi marked this pull request as ready for review December 16, 2025 10:55
Copy link
Contributor

@surbhigarg92 surbhigarg92 left a comment

Choose a reason for hiding this comment

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

Approving - The changes were already reviewed as part of #2235

@alkatrivedi alkatrivedi merged commit 0047e94 into main Dec 16, 2025
23 of 24 checks passed
@alkatrivedi alkatrivedi deleted the uuid-type-support branch December 16, 2025 11:44
gcf-merge-on-green bot pushed a commit that referenced this pull request Jan 9, 2026
🤖 I have created a release *beep* *boop*
---


## [8.4.0](https://togithub.com/googleapis/nodejs-spanner/compare/v8.3.1...v8.4.0) (2026-01-09)


### Features

* Add a ClientContext field to Spanner requests ([#2493](https://togithub.com/googleapis/nodejs-spanner/issues/2493)) ([37504ad](https://togithub.com/googleapis/nodejs-spanner/commit/37504adcc37a7e95acfb2530313ff783d0c1fe7d))
* Exposing total CPU related fields in AutoscalingConfig ([#2490](https://togithub.com/googleapis/nodejs-spanner/issues/2490)) ([508f0ff](https://togithub.com/googleapis/nodejs-spanner/commit/508f0ff95636b004f4200522018a199263eda8ca))
* **spanner:** Support for type UUID ([#2482](https://togithub.com/googleapis/nodejs-spanner/issues/2482)) ([0047e94](https://togithub.com/googleapis/nodejs-spanner/commit/0047e9407d86521571626c69011b70307f83f8ba))


### Bug Fixes

* **deps:** Update dependency google-gax to v5.0.6 ([#2452](https://togithub.com/googleapis/nodejs-spanner/issues/2452)) ([f9e6b86](https://togithub.com/googleapis/nodejs-spanner/commit/f9e6b86ff4da03110642c17e5ebc8fac8d903d3a))
* Flaky metric test ([#2472](https://togithub.com/googleapis/nodejs-spanner/issues/2472)) ([e169cc5](https://togithub.com/googleapis/nodejs-spanner/commit/e169cc5344d38812b1ebf20c7a987715a73d6f79))
* Memory leak and deadlock due to error event in multiplexed session ([#2477](https://togithub.com/googleapis/nodejs-spanner/issues/2477)) ([c624619](https://togithub.com/googleapis/nodejs-spanner/commit/c624619a3960892b1d2d412ff79faa5a74de45df))
* Presubmit failure for samples backups test ([#2492](https://togithub.com/googleapis/nodejs-spanner/issues/2492)) ([01eb3d5](https://togithub.com/googleapis/nodejs-spanner/commit/01eb3d5801ddb21517f185b9d585fbce4fa1475c))
* Type check for key in deleteRows ([#2486](https://togithub.com/googleapis/nodejs-spanner/issues/2486)) ([7347a16](https://togithub.com/googleapis/nodejs-spanner/commit/7347a1628ad8635b8f84b36ad1d3850b78862ac7))
* Type mismatch in Snapshot.run error handler ([#2487](https://togithub.com/googleapis/nodejs-spanner/issues/2487)) ([4ac0360](https://togithub.com/googleapis/nodejs-spanner/commit/4ac036047e3a03c073300f288c746389a38d8e42))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
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 googleapis/nodejs-spanner API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants