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

feat(spanner): support for type UUID #2235

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat(spanner): support for type UUID #2235

wants to merge 5 commits into from

Conversation

alkatrivedi
Copy link
Contributor

This PR contains support for UUID type on Cloud Spanner.

@alkatrivedi alkatrivedi requested review from a team as code owners February 8, 2025 07:40
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/nodejs-spanner API. labels Feb 8, 2025
@alkatrivedi alkatrivedi added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Feb 8, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 8, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 8, 2025
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Feb 11, 2025
@alkatrivedi alkatrivedi force-pushed the uuid-support branch 11 times, most recently from b31705d to 69cf752 Compare February 16, 2025 17:56
@alkatrivedi alkatrivedi added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Feb 17, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 17, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 17, 2025
@sakthivelmanii sakthivelmanii added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 17, 2025
@@ -5170,6 +5245,196 @@ describe('Spanner', () => {
});
});

// TODO: Enable when the uuid feature has been released.
describe.skip('uuid', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

have you tested this against cloud-devel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah

Copy link
Contributor

Choose a reason for hiding this comment

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

@sakthivelmanii We will be merging this when the feature is available in prod right ? So ideally we will remove this "skip" from the PR ?

@@ -814,6 +817,10 @@ function getType(value: Value): Type {
return {type: 'bool'};
}

if (uuid.validate(value)) {
return {type: 'unspecified'};
Copy link
Contributor

Choose a reason for hiding this comment

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

why unspecified here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cause we are not sure if the customer has inserted the UUID value in the column of type UUID/String. Hence, we are returning type as unspecified implicitly, but while making gRPC call we are making sure that if the type is unspecified we don't pass param type with the gaxOptions, this way are letting backend to figure out the type

Copy link
Contributor

Choose a reason for hiding this comment

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

@sakthivelmanii uuid value can be send for String column as well. So we want to make use of "unspecified" type and let backend decide it.
Ideally we should not have removed the type mapping when backend started suplorting untyped params, but we did not remove this because of breaking changes.

@@ -814,6 +817,10 @@ function getType(value: Value): Type {
return {type: 'bool'};
}

if (uuid.validate(value)) {
return {type: 'unspecified'};
Copy link
Contributor

Choose a reason for hiding this comment

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

@sakthivelmanii uuid value can be send for String column as well. So we want to make use of "unspecified" type and let backend decide it.
Ideally we should not have removed the type mapping when backend started suplorting untyped params, but we did not remove this because of breaking changes.

}
} else if (typeObject.code !== 'TYPE_CODE_UNSPECIFIED') {
paramTypes[param] = codec.createTypeObject(type);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can club this into single condition

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

@@ -427,6 +427,7 @@ describe('Spanner', () => {
before(async () => {
if (IS_EMULATOR_ENABLED) {
// TODO: add column Float32Value FLOAT32 and FLOAT32Array Array<FLOAT32> while using float32 feature.
Copy link
Contributor

Choose a reason for hiding this comment

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

@alkatrivedi Not in scope for this PR but can you work on this TODO sepaartely now that float32 should be available.

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. do not merge Indicates a pull request not ready for merge, due to either quality or timing. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants