Repository navigation
feat(spanner): Adds support for Cloud Spanner Locality Groups across INFORMATION_SCHEMA scanning, DDL generation, and Avro export/import - #4461
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 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.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4461 +/- ##
============================================
+ Coverage 58.04% 58.57% +0.53%
+ Complexity 8275 8041 -234
============================================
Files 1152 1153 +1
Lines 73713 74680 +967
Branches 8801 9039 +238
============================================
+ Hits 42784 43743 +959
+ Misses 28092 27995 -97
- Partials 2837 2942 +105
🚀 New features to boost your workflow:
|
f464de4 to
fb7c694
Compare
darshan-sj
left a comment
There was a problem hiding this comment.
Change looks good overall
952b5c6 to
f78b610
Compare
|
The smoke test failure seems to be unrelated this PR and is happening in other runs as well: https://github.com/GoogleCloudPlatform/DataflowTemplates/actions/runs/42613751848/job/129155248992 |
…pty default locality group
…utput in scanner tests
…ort in unit tests
f78b610 to
2044c1d
Compare
Summary
Adds support for Cloud Spanner Locality Groups across
INFORMATION_SCHEMAscanning, DDL generation, and Avro export/import for both GoogleSQL and PostgreSQL dialects.Note on the XXL size PR: the majority of the ~1,650 lines are unit/integration test cases across both dialects (LocalityGroupTest, DdlTest, InformationSchemaScannerTest, Avro converter tests, and InformationSchemaScannerIT), while the core production code changes are self-contained.
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.Production Readiness & Manual Testing (per Import/Export PR Review Guide)
spanner-export.json(locality_groupsis an optional repeated field inExportproto; existing exports withoutlocality_groupsimport cleanly).INFORMATION_SCHEMAAvailability: Verified thatINFORMATION_SCHEMA.LOCALITY_GROUP_OPTIONS(includingLOCALITY_GROUP_NAME,OPTION_NAME,OPTION_TYPE,OPTION_VALUE, andIS_INHERITED) is already GA and available in production Spanner for both GoogleSQL and PostgreSQL dialects.Manual Dataflow Template Test Results (Production Spanner)
Staged both
Cloud_Spanner_to_GCS_AvroandGCS_Avro_to_Cloud_Spannerfrom this branch and executed end-to-end Export → Import jobs on production Spanner:Baseline Database (Without Locality Groups — Backward Compatibility):
2026-11-02_15_22_59-17383155262102986919(Succeeded)2026-11-02_15_28_14-10411673572410755602(Succeeded)defaultlocality group export and import with zeroCREATE/ALTER LOCALITY GROUPDDL statements emitted and all table data intact.GoogleSQL Database With Locality Groups:
hdd,ssdwithssd_to_hdd_spill_timespan, and optionlessCREATE LOCALITY GROUP), altereddefaultlocality group (ALTER LOCALITY GROUP \default`), plus table-level, column-level override, inherited column-level, and index-levellocality_group` options.2026-11-02_15_23_01-1297557795690250884(Succeeded)2026-11-02_15_28_18-14807786884967534449(Succeeded)spanner-export.jsonand.avroschema artifacts; confirmedgcloud spanner databases ddl describeon destination DB matches source DDL (inherited column options were not redundantly emitted) and all rows were imported.PostgreSQL Database With Locality Groups:
STORAGE 'hdd',SSD_TO_HDD_SPILL_TIMESPAN, and optionless), altereddefaultlocality group, andLOCALITY GROUP "..."on tables, columns, and indexes.2026-11-02_15_23_03-10411673572410756259(Succeeded)2026-11-02_15_28_22-12493404610820383706(Succeeded)