Skip to content

feat: Add PostgreSQL REAL/FLOAT4 support to Sourcedb to Spanner template#3870

Merged
shreyakhajanchi merged 6 commits into
mainfrom
jsuhani-intern-2026
Jun 4, 2026
Merged

feat: Add PostgreSQL REAL/FLOAT4 support to Sourcedb to Spanner template#3870
shreyakhajanchi merged 6 commits into
mainfrom
jsuhani-intern-2026

Conversation

@jsuhani-2026
Copy link
Copy Markdown
Contributor

@jsuhani-2026 jsuhani-2026 commented Jun 2, 2026

The Sourcedb_to_Spanner_Flex template previously lacked support for migrating data from PostgreSQL REAL (aliased as FLOAT4) columns when using the Spanner PostgreSQL dialect. This resulted in data not being populated in the target Spanner tables for columns of type FLOAT4 (Spanner's single-precision float type), causing failures in PostgreSQLDataTypesPGDialectIT for these type tests.

This PR addresses this by:

  1. Adding Type Mapping: Introduced a type conversion mapping for Type.pgFloat4() in AvroToValueMapper.getPgMap(). This mapping utilizes the existing avroFieldToFloat32 function to correctly convert incoming Avro values (originating from PostgreSQL REAL columns) to Spanner Value.float32().
  2. Unit Tests: Added new unit tests to AvroToValueMapperTest.java to specifically validate the Dialect.POSTGRESQL map entries for Type.pgFloat4(), ensuring the conversion logic is correctly wired.
  3. Integration Tests: Re-enabled the integration test cases for REAL data types within PostgreSQLDataTypesPGDialectIT.java that were previously commented out. These tests now pass, confirming end-to-end functionality.

With these changes, the template now correctly handles PostgreSQL REAL/FLOAT4 types, mapping them to Spanner's float4 type in the PostgreSQL dialect.

Fixes: b/516973815

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.31%. Comparing base (d0ccc08) to head (466c250).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3870      +/-   ##
============================================
+ Coverage     55.47%   63.31%   +7.84%     
+ Complexity     6962     2315    -4647     
============================================
  Files          1102      514     -588     
  Lines         67443    29932   -37511     
  Branches       7564     3298    -4266     
============================================
- Hits          37413    18952   -18461     
+ Misses        27587    10017   -17570     
+ Partials       2443      963    -1480     
Components Coverage Δ
spanner-templates 88.72% <100.00%> (+0.92%) ⬆️
spanner-import-export ∅ <ø> (∅)
spanner-live-forward-migration 90.14% <100.00%> (-0.08%) ⬇️
spanner-live-reverse-replication 83.90% <100.00%> (+1.06%) ⬆️
spanner-bulk-migration 92.57% <100.00%> (-0.05%) ⬇️
gcs-spanner-dv 90.37% <100.00%> (+1.29%) ⬆️
Files with missing lines Coverage Δ
.../v2/spanner/migrations/avro/AvroToValueMapper.java 94.24% <100.00%> (+0.07%) ⬆️

... and 621 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jsuhani-2026 jsuhani-2026 marked this pull request as ready for review June 2, 2026 15:25
@jsuhani-2026 jsuhani-2026 requested a review from a team as a code owner June 2, 2026 15:25
@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 enables support for migrating PostgreSQL REAL (FLOAT4) data types within the Sourcedb to Spanner template. By establishing the necessary type mappings and validating them through both unit and integration tests, the changes ensure that single-precision floating-point data is correctly processed and persisted in Spanner when using the PostgreSQL dialect.

Highlights

  • Type Mapping Implementation: Added support for PostgreSQL REAL/FLOAT4 types by introducing a conversion mapping in AvroToValueMapper to correctly translate Avro values to Spanner float32.
  • Unit Testing: Expanded AvroToValueMapperTest to include validation for the new pgFloat4 mapping, ensuring proper handling of float inputs.
  • Integration Test Restoration: Re-enabled previously commented-out integration tests in PostgreSQLDataTypesPGDialectIT to verify end-to-end migration functionality for REAL data types.
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 the 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 counterproductive. 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.

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
Copy Markdown
Contributor

@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 enables mapping support for PostgreSQL float4 (real) to Spanner float32 in AvroToValueMapper and re-enables the corresponding integration tests in PostgreSQLDataTypesPGDialectIT. Feedback suggests removing obsolete comments in the integration tests that claim the float4 tests are still commented out, and expanding the unit tests in AvroToValueMapperTest to cover null, NaN, and infinity values as described in the PR description.

@jsuhani-2026 jsuhani-2026 requested a review from sm745052 June 3, 2026 04:24
Copy link
Copy Markdown
Contributor

@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

Copy link
Copy Markdown
Contributor

@sm745052 sm745052 left a comment

Choose a reason for hiding this comment

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

LGTM

@shreyakhajanchi shreyakhajanchi merged commit d2ed574 into main Jun 4, 2026
26 checks passed
@shreyakhajanchi shreyakhajanchi deleted the jsuhani-intern-2026 branch June 4, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants