Skip to content

Move Postgres and SQL Server boundary handling into dialect adapters - #4645

Draft
dhwanilpatel wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
dhwanilpatel:pk_splitter_dialect_hooks
Draft

dhwanilpatel wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
dhwanilpatel:pk_splitter_dialect_hooks

Conversation

@dhwanilpatel

Copy link
Copy Markdown
Contributor

The uniform splitter is meant to be dialect-neutral, but special cases for Postgres uuid, bit and time 24:00:00 and SQL Server uniqueidentifier sat in shared reader code (BoundaryExtractorFactory and both statement setters), chosen only by column type name. Shared code imported the Postgres driver, and the UUID/GUID conversion was duplicated in both setters.

Add two general UniformSplitterDBAdapter methods, with defaults that keep the MySQL and Oracle behaviour:

  • extractBinaryBoundary: how to read a binary boundary.
  • toQueryParameter: how to convert a boundary before binding it, used by RangePreparedStatementSetter and ColumnForBoundaryQueryPreparedStatementSetter.

PostgreSQLDialectAdapter and SqlServerDialectAdapter take over their cases; the SQL Server byte order moves to SqlServerUniqueIdentifier. The setters take the adapter from RangeCountDoFn, RangeBoundaryDoFn and ReadWithUniformPartitions, which already hold it.

Same boundaries, SQL and bound values for range reads and counts. The boundary query setter now also applies the Postgres bit and 24:00:00 conversions to parent ranges, as the range setter already did.

The uniform splitter is meant to be dialect-neutral, but special cases for
Postgres uuid, bit and time 24:00:00 and SQL Server uniqueidentifier sat in
shared reader code (BoundaryExtractorFactory and both statement setters),
chosen only by column type name. Shared code imported the Postgres driver,
and the UUID/GUID conversion was duplicated in both setters.

Add two general UniformSplitterDBAdapter methods, with defaults that keep
the MySQL and Oracle behaviour:
- extractBinaryBoundary: how to read a binary boundary.
- toQueryParameter: how to convert a boundary before binding it, used by
  RangePreparedStatementSetter and ColumnForBoundaryQueryPreparedStatementSetter.

PostgreSQLDialectAdapter and SqlServerDialectAdapter take over their cases;
the SQL Server byte order moves to SqlServerUniqueIdentifier. The setters
take the adapter from RangeCountDoFn, RangeBoundaryDoFn and
ReadWithUniformPartitions, which already hold it.

Same boundaries, SQL and bound values for range reads and counts. The
boundary query setter now also applies the Postgres bit and 24:00:00
conversions to parent ranges, as the range setter already did.
@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.78082% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.42%. Comparing base (2a90bcc) to head (f6f8b9b).
⚠️ Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...ctadapter/postgresql/PostgreSQLDialectAdapter.java 88.88% 2 Missing and 1 partial ⚠️
...jdbc/uniformsplitter/UniformSplitterDBAdapter.java 50.00% 1 Missing ⚠️
...niformsplitter/range/BoundaryExtractorFactory.java 90.00% 0 Missing and 1 partial ⚠️
...ctadapter/sqlserver/SqlServerUniqueIdentifier.java 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4645      +/-   ##
============================================
+ Coverage     59.75%   66.42%   +6.67%     
+ Complexity     7926     2975    -4951     
============================================
  Files          1123      553     -570     
  Lines         72705    32563   -40142     
  Branches       8842     3764    -5078     
============================================
- Hits          43447    21631   -21816     
+ Misses        26362     9862   -16500     
+ Partials       2896     1070    -1826     
Components Coverage Δ
spanner-templates 84.02% <91.78%> (-0.01%) ⬇️
spanner-import-export ∅ <ø> (∅)
spanner-live-forward-migration 87.61% <ø> (-0.05%) ⬇️
spanner-live-reverse-replication 79.91% <ø> (-0.04%) ⬇️
spanner-bulk-migration 88.28% <91.78%> (-0.01%) ⬇️
gcs-spanner-dv 86.53% <ø> (-0.05%) ⬇️
Files with missing lines Coverage Δ
...ColumnForBoundaryQueryPreparedStatementSetter.java 100.00% <100.00%> (+2.17%) ⬆️
...rmsplitter/range/RangePreparedStatementSetter.java 100.00% <100.00%> (+10.00%) ⬆️
.../uniformsplitter/transforms/RangeBoundaryDoFn.java 94.33% <ø> (ø)
...dbc/uniformsplitter/transforms/RangeCountDoFn.java 95.83% <100.00%> (ø)
...splitter/transforms/ReadWithUniformPartitions.java 100.00% <100.00%> (ø)
...lectadapter/sqlserver/SqlServerDialectAdapter.java 76.20% <100.00%> (+0.63%) ⬆️
...jdbc/uniformsplitter/UniformSplitterDBAdapter.java 7.14% <50.00%> (+7.14%) ⬆️
...niformsplitter/range/BoundaryExtractorFactory.java 98.00% <90.00%> (-0.25%) ⬇️
...ctadapter/sqlserver/SqlServerUniqueIdentifier.java 94.11% <94.11%> (ø)
...ctadapter/postgresql/PostgreSQLDialectAdapter.java 89.61% <88.88%> (-0.07%) ⬇️

... and 597 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant