Repository navigation
feat(spanner): Adds support for Cloud Spanner Locality Groups across INFORMATION_SCHEMA scanning, DDL generation, and Avro export/import - #4461
Conversation
…pty default locality group
…utput in scanner tests
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 adds comprehensive support for Cloud Spanner Locality Groups, allowing for the preservation and migration of locality group configurations. The changes span the entire pipeline, including schema scanning, DDL generation, and Avro-based export/import processes, ensuring full compatibility for both GoogleSQL and PostgreSQL dialects. 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 Cloud Spanner Locality Groups across the Spanner Teleport templates, including schema conversion, import/export transforms, and information schema scanning. Feedback on the changes suggests simplifying the extraction of numbered options in AvroSchemaToDdlConverter by reusing the getNumberedPropsWithPrefix helper. Additionally, it is recommended to wrap the ResultSet objects in try-with-resources blocks within InformationSchemaScanner's listTableOptions and listLocalityGroups methods to prevent potential resource leaks.
Summary
Adds support for Cloud Spanner Locality Groups across
INFORMATION_SCHEMAscanning, DDL generation, and Avro export/import for both GoogleSQL and PostgreSQL dialects.Key Changes
LocalityGroup,Ddl,Table,Column,Index):LocalityGroupvalue class and builder to represent locality groups inDdl.CREATE LOCALITY GROUPfor user-created locality groups (with or without options) andALTER LOCALITY GROUPfor thedefaultlocality group when its options have been customized.OPTIONS (storage="...", ssd_to_hdd_spill_timespan="...")) and PostgreSQL (STORAGE '...' SSD_TO_HDD_SPILL_TIMESPAN '...').LOCALITY GROUP "..."DDL rendering onTable,Column, andIndex.createLocalityGroupStatements()beforecreateTableStatements()andcreateIndexStatements()inDdl.statements()so locality groups exist before being referenced by tables, columns, or indexes.InformationSchemaScanner):listLocalityGroups()queryinginformation_schema.locality_group_options.CREATE LOCALITY GROUP <name>) and altereddefaultlocality groups (is_inherited = FALSE/'NO'), while skipping unmodifieddefaultlocality groups.listTableOptions(),listColumnOptions(), andlistIndexOptions().listColumnOptions()to filter out inherited column options (is_inherited = TRUE/'YES') so columns inheriting a table's locality group do not emit redundant column-level options.DdlToAvroSchemaConverter,AvroSchemaToDdlConverter,ExportTransform,ImportTransform,export.proto):LocalityGroupentities as schema-only Avro records ("spannerEntity": "LocalityGroup") and reconstructs them back intoDdl.locality_groupsto theExportmanifest proto and wired locality group DDL creation intoImportTransformprior to table creation.Testing
LocalityGroupTest&DdlTest: DDL formatting and statement ordering for custom, optionless, and altereddefaultlocality groups, plus table, column, and index locality group options in GoogleSQL and PostgreSQL.InformationSchemaScannerTest: Unit tests forlistLocalityGroups,listTableOptions,listColumnOptions(verifying inherited column options are skipped and explicit overrides are kept), andlistIndexOptionsacross both dialects.DdlToAvroSchemaConverterTest,AvroSchemaToDdlConverterTest, &ExportTransformTest: Avro schema conversion, manifest generation, and round-trip DDL reconstruction for locality groups (with and without options) and table/column/index assignments.InformationSchemaScannerIT: End-to-end Spanner ITs (localityGroupsandpgLocalityGroups) verifyingINFORMATION_SCHEMAscanningDdlAvroDdlround-trip in both GoogleSQL and PostgreSQL.