Skip to content

fix: Support PostgreSQL VECTOR LENGTH types in Spanner change streams - #4169

Open
mvanhorn wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
mvanhorn:fix/4120-spanner-vector-length-types
Open

mvanhorn wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
mvanhorn:fix/4120-spanner-vector-length-types

Conversation

@mvanhorn

Copy link
Copy Markdown

Extend the PostgreSQL information-schema parser in TypesUtils to recognize the repository's existing embedding-vector grammar, isolate the array element type, and ignore the vector-length constraint when constructing the Cloud Spanner client Type, consistent with the utility's existing treatment of parameterized lengths. The Spanner change-streams-to-BigQuery template fails during worker setup when a PostgreSQL-dialect table tracked by the change stream contains an embedding-vector column such as real[] VECTOR LENGTH 512.

Convert real[] vector length 512 from PostgreSQL information schema and verify it produces an array of FLOAT32, allowing schema setup for the reported embedding column; Convert a case-varied DOUBLE PRECISION[] VECTOR LENGTH 4 and verify it produces an array of FLOAT64, demonstrating that parsing follows the documented grammar rather than hard-coding the reported input.

Fixes #4120

@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 PostgreSQL embedding-vector columns within the Spanner change-streams-to-BigQuery template. By updating the schema parsing utility to recognize and strip vector length constraints, the system can now successfully process tables containing vector data types without failing during worker setup.

Highlights

  • PostgreSQL Vector Type Support: Added regex-based parsing to TypesUtils to correctly identify and handle PostgreSQL 'VECTOR LENGTH' types in Spanner change streams.
  • Schema Parsing Logic: Updated the information schema parser to isolate the array element type and ignore vector length constraints, ensuring compatibility with Spanner's type system.
  • Test Coverage: Expanded unit tests to verify correct type mapping for vector columns and added validation to reject invalid vector length configurations.
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. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 adds support for parsing PostgreSQL vector types (e.g., real[] VECTOR LENGTH 512) and mapping them to Spanner array types in TypesUtils, along with corresponding unit tests. The reviewer suggested using a dummy type name instead of integer in the negative test case to prevent the test from becoming fragile if integer support is added in the future.

@derrickaw derrickaw added addition New feature or request and removed addition New feature or request labels Aug 21, 2026
@stankiewicz stankiewicz added the addition New feature or request label Sep 28, 2026
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.37%. Comparing base (9acecbd) to head (5b015f1).
⚠️ Report is 209 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4169      +/-   ##
============================================
+ Coverage     55.89%   56.37%   +0.47%     
- Complexity     7020     7413     +393     
============================================
  Files          1134     1155      +21     
  Lines         70098    73233    +3135     
  Branches       8006     8586     +580     
============================================
+ Hits          39183    41286    +2103     
- Misses        28371    29159     +788     
- Partials       2544     2788     +244     
Components Coverage Δ
spanner-templates 84.46% <ø> (-0.25%) ⬇️
spanner-import-export 68.90% <ø> (-0.03%) ⬇️
spanner-live-forward-migration 88.91% <ø> (+0.07%) ⬆️
spanner-live-reverse-replication 80.82% <ø> (-0.58%) ⬇️
spanner-bulk-migration 88.96% <ø> (-0.20%) ⬇️
gcs-spanner-dv 88.02% <ø> (-0.03%) ⬇️
Files with missing lines Coverage Δ
...hangestreamstobigquery/schemautils/TypesUtils.java 69.64% <100.00%> (+9.64%) ⬆️

... and 69 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.
The negative vector-length test call exceeded the formatter's line
length, which failed the Java PR Spotless check.
@mvanhorn

Copy link
Copy Markdown
Author

Wrapped the long assertThrows line in TypesUtilsTest that was failing Spotless, and merged the latest main into the branch (e7235f6). mvn spotless:check and mvn checkstyle:check on v2/googlecloud-to-googlecloud both pass locally with JDK 17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition New feature or request size/M

3 participants