Repository navigation
[SpannerToSourceDb] Add bytesToHex and Spanner value helpers to DMLGeneratorUtils - #4667
Closed
aasthabharill wants to merge 3 commits into
Closed
aasthabharill wants to merge 3 commits into
aasthabharill wants to merge 3 commits into
Conversation
This was referenced Dec 1, 2026
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4667 +/- ##
============================================
+ Coverage 59.72% 66.47% +6.75%
+ Complexity 8218 3343 -4875
============================================
Files 1122 552 -570
Lines 72762 32717 -40045
Branches 8855 3793 -5062
============================================
- Hits 43454 21750 -21704
+ Misses 26405 9886 -16519
+ Partials 2903 1081 -1822
🚀 New features to boost your workflow:
|
Member
Author
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
Part 3 of 7 for migrating
v2/spanner-to-sourcedbJDBC reverse-replication writers toPreparedStatementexecution (follows #4662 and #4666; split out of combined prototype #4655).This PR is self-contained and safe to merge on its own: it replaces per-byte
String.formathex conversion inDMLGeneratorUtils.convertBase64ToRawHexwith a zero-allocation lookup-tablebytesToHexhelper, and adds shared Spanner JSON value, non-finite float/numeric, and NUL-byte helpers used by parameterized DML generators.Implementation & Why
DMLGeneratorUtils(dbutils/dml/DMLGeneratorUtils.java):bytesToHex(byte[])using aHEX_DIGITSlookup string and switchedconvertBase64ToRawHexto use it (eliminating per-byteString.formatallocations on binary columns).isFloatOrNumeric,isNonFiniteLiteral, andgetNonFiniteTextso JDBC generators detectNaN,Infinity,+Infinity, and-Infinitybefore callingJSONObject.getBigDecimal(which throwsNumberFormatException/JSONException).getSpannerStringValue(preserving exact decimal text on string-encodedNUMERIC/PG_NUMERICinstead of reformatting0.0000001as1E-7, avoidingFloat->doublewidening noise on programmaticFloats, and keeping legacyARRAY<STRING>comma-joining for scalar text columns) andremoveNullBytes.DMLGeneratorUtilsTest.java):@RunWith(JUnit4.class)and unit teststestBytesToHex,testNonFiniteHelpers, andtestGetSpannerStringValue_PreservesNumericDecimalTextAndFormatsTypes.Verification
mvn -pl v2/spanner-common,v2/spanner-custom-shard,v2/spanner-to-sourcedb test spotless:check(Checkstyle, Spotless, and unit tests passed).Series Context
JdbcDaoleak/rollback fix), [SpannerToSourceDb] Add PreparedStatementValue and JdbcDao typed binding #4666 (PreparedStatementValue+JdbcDaodispatch).DMLGeneratorUtilsbytesToHexand Spanner value/non-finite helpers.DMLGeneratorUtils.getColumnValues/getPkColumnValuesonto a shared generic column walker and fixes the legacy null custom-transformation NPE across MySQL, Oracle, and SQL Server.ColumnBindingandDMLGeneratorUtils.getColumnBindings/getPkColumnBindings.PostgreSQLDMLGeneratorontoPreparedStatementbinding + unit tests + docs.SpannerToPostgreSQLDataTypesITacross 11 non-bigint PK types, enums, non-finite floats, and generated-PK CRUD.