Repository navigation
Conversation
Cloud Spanner search indexes can be partitioned by the elements of an array column using an UNNEST clause, for example: CREATE SEARCH INDEX AlbumsByTracks ON Albums(AlbumTitle_Tokens) UNNEST(Tracks) AS Track PARTITION BY Track The export scanner did not read the UNNEST clause, so it emitted "... PARTITION BY Track" without it, and importing that DDL failed because Track is not a column. InformationSchemaScanner now reads INFORMATION_SCHEMA.INDEXES.SEARCH_UNNEST (when the column exists) and Index prints the UNNEST clauses after the indexed columns, before STORING (GoogleSQL) or INCLUDE (PostgreSQL), matching GetDatabaseDdl. The column is probed first so export keeps working against databases and environments (e.g. the emulator) that don't expose it.
5b786d7 to
527fc28
Compare
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 addresses an issue where Cloud Spanner search indexes partitioned by repeated values were failing to export/import correctly due to missing UNNEST clause information. The changes introduce logic to detect and extract this information from the database schema and ensure it is correctly represented in the generated DDL, while maintaining compatibility with environments that do not yet support this schema column. 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 introduces support for UNNEST clauses in Spanner search indexes, allowing partitioning by repeated values. It updates the Index model to include unnest fields, implements dialect-specific pretty-printing, and updates InformationSchemaScanner to dynamically query the SEARCH_UNNEST column if supported. Comprehensive unit and integration tests are also added. A critical issue was identified in Index.java where quoting a dotted column path (e.g., nested fields) as a single identifier is invalid in Spanner; each part of the path should be quoted individually to prevent DDL import failures.
|
cc @n-d-joshi |
Cloud Spanner search indexes can be partitioned by the elements of an array column using an UNNEST clause, for example:
CREATE SEARCH INDEX AlbumsByTracks ON Albums(AlbumTitle_Tokens)
UNNEST(Tracks) AS Track PARTITION BY Track
The export scanner did not read the UNNEST clause, so it emitted "... PARTITION BY Track" without it, and importing that DDL failed because Track is not a column.
InformationSchemaScanner now reads INFORMATION_SCHEMA.INDEXES.SEARCH_UNNEST (when the column exists) and Index prints the UNNEST clauses after the indexed columns, before STORING (GoogleSQL) or INCLUDE (PostgreSQL), matching GetDatabaseDdl. The column is probed first so export keeps working against databases and environments (e.g. the emulator) that don't expose it.