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

Support FLOAT32 type in Spanner Migration Tool. #872

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

arawind
Copy link
Contributor

@arawind arawind commented Jul 17, 2024

This changes the existing behavior of widening a source float32 type into float64 in spanner, and instead mapping the source float32 type to spanner's new float32 type.

This is a re-patch of #785

  • Tests pass
  • Appropriate changes to README are included in PR

@arawind arawind requested a review from a team as a code owner July 17, 2024 03:14
@arawind arawind requested review from manitgupta and asthamohta and removed request for a team July 17, 2024 03:14
@manitgupta
Copy link
Member

Actually this made me wonder if the changes around Float32 - Dataflow and SMT, are backward compatible?

If I have a customer who has already mapped float to float64 in a previous schema migration, and uses the new dataflow template with the changes you made recently, will anything break?

Please walk through the cases therein once. (Schema version X Dataflow template version)

@arawind
Copy link
Contributor Author

arawind commented Jul 17, 2024

@manitgupta IIUC if the spanner migration tool has already converted a schema and float32 from sourcedb is mapped to float64 in spanner, DataFlow will still process the events correctly as float64 values.

I believe this happens because DataFlow templates use the current Spanner schema to make the choice of whether to parse the input change as FLOAT64 or FLOAT32.

So these steps should result in a backward compatible migration. LMK if I missed something!

@manitgupta
Copy link
Member

Yes, you're right. The spanner schema is used to infer the data type. So last as long the spanner schema has something that the pipeline is able to cast to, we will be good.

On the other hand, if the customer decides to regenerate the spanner schema using SMT, there data types will change to Float32 from Float64. This should be okay if the customer is redoing a migration.

This leaves only the load from session file scenario which I think is worth validating -

Consider this example -

  1. Customer did a schema migration and generated a session file.
  2. Customer wants to rename a column now from A -> B.
  3. Customer loads the session file into SMT.
  4. Customer makes the change to the column name.

Can you validate what is the value of spanner data type that appears from when loading from session file? Ideally, it should load from spSchema and hence the newly changed defaults should not matter.

@arawind
Copy link
Contributor Author

arawind commented Jul 17, 2024

Thanks @manitgupta!

As mentioned offline, I've verified that the loading the old session file still uses the previous mapping of FLOAT32 source => FLOAT64 in spanner and does not change it to FLOAT32 in spanner.

Copy link
Collaborator

@shreyakhajanchi shreyakhajanchi left a comment

Choose a reason for hiding this comment

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

Just one comment regarding float -> FLOAT64 mapping option

sources/mysql/toddl.go Show resolved Hide resolved
@arawind
Copy link
Contributor Author

arawind commented Jul 19, 2024

@manitgupta @shreyakhajanchi gentle ping!

@arawind arawind force-pushed the float32 branch 2 times, most recently from 4a3ad4c to f8f14f9 Compare July 19, 2024 07:30
Copy link
Collaborator

@shreyakhajanchi shreyakhajanchi left a comment

Choose a reason for hiding this comment

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

LGTM

This changes the existing behavior of widening a source float32 type into float64 in spanner, and instead mapping the source float32 type to spanner's new float32 type.
We still allow float32 to be manually mapped to float64 if the customer intends to do that.
@shreyakhajanchi shreyakhajanchi merged commit 34387bc into GoogleCloudPlatform:master Jul 25, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants