Repository navigation
Postgres prevent index name collisions across schemas during non-publ… - #4412
SaurabhSingh2115 wants to merge 2 commits into
Conversation
…ic schema migration
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 a bug in the PostgreSQL dialect adapter where index discovery could incorrectly match indexes from non-target schemas due to name collisions. By enforcing a namespace check during the join process, the system now correctly identifies indexes associated with the intended schema, preventing data inconsistencies during migration. 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 updates the PostgreSQL dialect adapter to join pg_catalog.pg_class with pg_catalog.pg_namespace when discovering table indexes. This ensures that index names are correctly matched within their respective schemas, preventing collisions when identical index names exist across different schemas. A corresponding unit test has been added to verify this SQL query structure. There are no review comments, and we have no feedback to provide.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4412 +/- ##
============================================
+ Coverage 57.00% 63.85% +6.85%
+ Complexity 8029 3079 -4950
============================================
Files 1156 577 -579
Lines 73694 34066 -39628
Branches 8691 3885 -4806
============================================
- Hits 42007 21752 -20255
+ Misses 28891 11215 -17676
+ Partials 2796 1099 -1697
🚀 New features to boost your workflow:
|
bharadwaj-aditya
left a comment
There was a problem hiding this comment.
Please check if it is feasible to add an integration test here. (preferably add to an existing integration test)
| adapter.discoverTableIndexes(mockDataSource, sourceSchemaReference, ImmutableList.of("orders")); | ||
|
|
||
| // Index names are unique only within a schema, e.g. public.orders_pkey and tenant.orders_pkey. | ||
| verify(mockConnection) |
There was a problem hiding this comment.
The UT is fine, but it would be good to have an integration test for this to ensure this works on PG ?
When migrating only the 'public' schema while ignoring tables in other schemas (such as
sales or archive), PostgreSQL default primary key indices (e.g., orders_pkey) share identical
names across schemas.
Previously, PostgreSQLDialectAdapter queried table indices by index name alone without verifying
its schema namespace. Consequently, when a public table shared its name and index name with a
non-public table, Dataflow erroneously pulled primary key columns from the non-public schema table,
resulting in pipeline failures (e.g., column "order_no" does not exist).