Repository navigation
[SpannerToSourceDb] Expand SpannerToPostgreSQLDataTypesIT CRUD and PK coverage - #4665
aasthabharill wants to merge 7 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4665 +/- ##
============================================
+ Coverage 60.34% 67.93% +7.59%
+ Complexity 8965 3649 -5316
============================================
Files 1125 555 -570
Lines 72994 33079 -39915
Branches 8888 3842 -5046
============================================
- Hits 44049 22473 -21576
+ Misses 26016 9496 -16520
+ Partials 2929 1110 -1819
🚀 New features to boost your workflow:
|
7f5ef63 to
828d046
Compare
828d046 to
4a7b5a7
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 introduces significant improvements to the PostgreSQL reverse replication process by moving to a fully parameterized PreparedStatement approach. This change ensures that data types are correctly handled by the PostgreSQL driver, preventing issues with unquoted identifiers or incorrect type resolution. The PR also significantly expands the integration test suite to validate these changes against real Cloud Spanner and PostgreSQL instances, ensuring robust support for various data types and primary key configurations. 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 Spanner-to-PostgreSQL reverse replication template to use strictly parameterized DML statements with PreparedStatement bindings instead of raw SQL fragments. It introduces PreparedStatementValue.ofUntypedString using Types.OTHER to allow PostgreSQL to natively parse string parameters into target column types like jsonb, uuid, and enums. The PostgreSQLDMLGenerator has been refactored to handle type-specific bindings, strip NUL characters, format bytes as hex, and support non-finite floating-point values. Additionally, integration tests and schemas have been expanded to cover INSERT, UPDATE, and DELETE operations across a wide range of PostgreSQL data types and primary key configurations. I have no further feedback to provide.
…ases - Restore the list + String.join form of getUpsertStatement and the INTEGER_LITERAL regex, replacing the hand-written fast paths. - PgColumnType.fromSourceType does a single normalized lookup. - Inline getBooleanBindingValue and formatConversionError; make isSpannerFloat a local variable. - isNonFiniteTrimmed uses a Locale.ROOT lower-cased set lookup again, so only ASCII spellings of NaN / Infinity match (equalsIgnoreCase also matched the Turkish dotless and dotted i). - Reword comments on NULL timestamp placeholders and dropped exception causes to say what the code guarantees. - Tests: string "false" into boolean columns, non-finite text via Spanner STRING and custom values, INT64 string edge cases (0, -0, out of long range, non-numeric, BigInteger), and decimals in the shape org.json parses from text.
4a7b5a7 to
195d9cc
Compare
… sources - getNullColumnBinding returns a NULL with the JDBC type of the column's non-null values (VARCHAR, BIGINT, BOOLEAN, DOUBLE, DECIMAL, VARBINARY). pgjdbc reuses a server-prepared statement only while parameter types stay the same, so an untyped NULL forced a Close and re-Parse whenever a column switched between NULL and a value. Timestamp and untyped (Types.OTHER) columns keep an untyped NULL, which already matches their values. - Null custom transformation values use the same mapping. - Oracle and SQL Server call DMLGeneratorUtils.removeNullBytes instead of their own inline copy of the same replace. - Tests: one test pinning that a NULL binds with the placeholder and parameter type of the column's values, and updated NULL expectations.
195d9cc to
f0ca6e7
Compare
Why This Change Is Required
SpannerToPostgreSQLDataTypesITpreviously only testedINSERTintobigint-PK tables for a small set of scalar types. Because #4664 changes howPostgreSQLDMLGeneratorbinds parameter OIDs acrossINSERT,UPDATE, andDELETE, we need real Spanner-to-PostgreSQL integration coverage to verifyrealPK deletes, non-finite floats,USER-DEFINEDenums,time without time zone,character(n)padding, andIS NULLgenerated-PK deletes end to end.Changes Made & What They Do
postgresql-schema.sql&spanner-schema.sql:real(NaN,Infinity,-Infinity,1.1),bytes_to_text,time without time zone,timestamp without time zone, andmood_enum(USER-DEFINEDENUM).bigintprimary-key tables (real,double precision,numeric,uuid,date,timestamptz,bytea,boolean,integer,textwith quotes,character(10)).gen_pk_tablewith aGENERATED ALWAYS AS (...) STORED PRIMARY KEY.SpannerToPostgreSQLDataTypesIT.java:INSERT): Inserts across all datatype tables, all 11 non-bigintPK tables (including exact-length, shorter, and trailing-space keys oncharacter(10)), andgen_pk_table; verifies exact row counts and column/PK values.UPDATE): Updates all 11 PK tables and updatesgen_pk_table.last_nametoNULLviaON CONFLICT DO UPDATE SET.DELETE): Deletes all 11 PK tables andgen_pk_table(verifying symmetrical PK binding and"last_name" IS NULLmatching); asserts 0 remaining rows.assertRowInPostgreSQLwith exact row-count (hasSize) checks.Verification
JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64,-Dbeam.version=2.77.0):mvn -pl v2/spanner-common,v2/spanner-custom-shard,v2/spanner-to-sourcedb test:SpannerToPostgreSQLDataTypesITcompiles cleanly, 1,243 unit tests passed, 0 Checkstyle violations.mvn -pl v2/spanner-to-sourcedb spotless:check: passed.Build,Checkstyle,Spotless,Unit Tests,Dataflow Templates Integration Smoke Tests, andDataflow Templates Integration Tests(including the expandedSpannerToPostgreSQLDataTypesITagainst real Cloud Spanner, Dataflow, and PostgreSQL) all passed.Related / Follow-up PRs
mainand pass with [SpannerToSourceDb] Migrate PostgreSQLDMLGenerator to PreparedStatement binding #4664).PreparedStatementlayer).