Repository navigation
[SpannerToSourceDb] Use prepared statements for Spanner to PostgreSQL - #4655
Draft
aasthabharill wants to merge 1 commit into
Draft
aasthabharill wants to merge 1 commit into
aasthabharill wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4655 +/- ##
============================================
+ Coverage 59.69% 66.60% +6.91%
+ Complexity 8678 3467 -5211
============================================
Files 1122 553 -569
Lines 72738 32990 -39748
Branches 8854 3873 -4981
============================================
- Hits 43418 21972 -21446
+ Misses 26419 9918 -16501
+ Partials 2901 1100 -1801
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates
PostgreSQLDMLGeneratorinv2/spanner-to-sourcedbfrom string-concatenated SQL toPreparedStatementparameter binding, lifting shared JDBC binding abstractions intodbutils/dml/andJdbcDaoso other JDBC dialects (such as #4644 for MySQL) can reuse them without duplication.Changes
dbutils/dml/):PreparedStatementValueandColumnBindingincom.google.cloud.teleport.v2.templates.dbutils.dml.getColumnBindings/getPkColumnBindings(with a customizablenullBindingMapperoverload for future Oracle/SQL Server reuse) and shared Spanner value helpers inDMLGeneratorUtils. LegacygetColumnValues/getPkColumnValuesare kept intact for un-migrated dialects.JdbcDaoexecution (dbutils/dao/source/JdbcDao.java):bindParametersupport forPreparedStatementValue(includingTypes.OTHERfor PostgreSQL untyped string binding,Float, and typedsetNull), while retaining legacy raw parameter binding and the rawStatementfallback for Oracle and SQL Server.ConnectionandStatement/PreparedStatementto try-with-resources with explicitrollback()on failure so pooled connections cannot leak whenstatement.close()throws.PostgreSQLDMLGenerator(source/postgres/PostgreSQLDMLGenerator.java):NULL,customTransformationResponseoutput, and unknown/default column type as aPreparedStatementparameter (never concatenated into SQL)."->"") in all table and column identifiers acrossINSERT,ON CONFLICT,DO UPDATE SET ... EXCLUDED, andDELETE ... WHERE.pgjdbccompatibility:Types.OTHERforjson/jsonb/uuid/date/time/timetz/arrays/enums/unknown types,?::timestamptzfor Spanner timestamps,ofLongfor integer columns (preserving PK B-tree indexes),ofFloatforreal/float4,ofDoublefordouble precision/float8, boundedBigDecimalfornumeric/decimal(preserving scientific-notation precision while preventing large-string DoS),ofBooleanstrictly forboolean,IS NULLfor null predicates in generated-PK deletes, and{...}formatting (with Base64-decoded\x...hex forbytea[]) for native PostgreSQL array columns.PreparedStatementValueTestand expandedDMLGeneratorUtilsTest,JdbcDaoTest(mockingIConnectionHelperwithout mutating static pool state), andPostgreSQLDMLGeneratorTest(including symmetricalDELETEcoverage, generated PKs, cross-type safety, and SQL injection regression tests).Verification
mvn -pl v2/spanner-common,v2/spanner-to-sourcedb test(Checkstyle + 518 tests inspanner-common, 628 tests inspanner-to-sourcedb: all passed)mvn -pl v2/spanner-to-sourcedb spotless:check(passed)