fix: Support PostgreSQL VECTOR LENGTH types in Spanner change streams - #4169
fix: Support PostgreSQL VECTOR LENGTH types in Spanner change streams#4169mvanhorn wants to merge 1 commit into
Conversation
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| () -> TypesUtils.informationSchemaPostgreSQLTypeToSpannerType("real[] vector length 0")); | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> TypesUtils.informationSchemaPostgreSQLTypeToSpannerType("integer[] vector length 4")); |
There was a problem hiding this comment.
Using integer as an unsupported type in this test makes it fragile, as integer is a standard PostgreSQL type that might be supported in the future. If support for integer is added, this test will fail. Consider using a completely dummy/unsupported type name (e.g., unsupportedtype) to ensure the test remains robust and future-proof.
| () -> TypesUtils.informationSchemaPostgreSQLTypeToSpannerType("integer[] vector length 4")); | |
| () -> TypesUtils.informationSchemaPostgreSQLTypeToSpannerType("unsupportedtype[] vector length 4")); |
Extend the PostgreSQL information-schema parser in
TypesUtilsto recognize the repository's existing embedding-vector grammar, isolate the array element type, and ignore the vector-length constraint when constructing the Cloud Spanner clientType, 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 asreal[] VECTOR LENGTH 512.Convert
real[] vector length 512from PostgreSQL information schema and verify it produces an array ofFLOAT32, allowing schema setup for the reported embedding column; Convert a case-variedDOUBLE PRECISION[] VECTOR LENGTH 4and verify it produces an array ofFLOAT64, demonstrating that parsing follows the documented grammar rather than hard-coding the reported input.Fixes #4120