DanielLeens opened a new pull request, #13513:
URL: https://github.com/apache/seatunnel/pull/13513

   Yes, I am contributing to Apache SeaTunnel.
   
   Fixes #13511.
   
   ## Problem and root cause
   
   Generated SQL Server JDBC batches become fragmented when decimal values 
alternate with NULL. Microsoft JDBC 9.4.1 declares non-null parameters as 
decimal(38, scale), but the existing untyped NULL path subsequently changes 
their scale to zero. This repeatedly changes prepared parameter declarations 
inside a batch.
   
   Three baseline full-job pairs reproduced DataX/SeaTunnel throughput ratios 
of 1.779 x, 1.744 x and 1.733 x with exact destination values. Independent 
JDBC-component pairs reproduced the same gap; the issue contains both complete 
matrices and the history back to #2646/#4917. This is a longstanding 
performance issue, not a newly introduced data-loss regression.
   
   ## Changes and compatibility
   
   - Add an internal SQL Server generated-DML converter that supplies the 
declared decimal scale for NULL through standard JDBC setObject(index, null, 
Types.DECIMAL, scale).
   - Require both a logical DecimalType with scale 0–38 and destination 
metadata identifying DECIMAL/NUMERIC. Other destination types, missing metadata 
and unsupported logical scales retain their original NULL binding.
   - Select it only for generated INSERT/MERGE/UPDATE statements and the exact 
SqlServerDialect class. Unrestricted custom SQL, DELETE, sources and dialect 
subclasses retain the existing converter.
   - Keep all non-null setters and existing binary NULL behavior unchanged. No 
API/SPI, option/default, dependency or POM changes.
   - Extend existing JdbcSqlServerIT and update English/Chinese sink 
documentation.
   
   These boundaries are required by actual compatibility reproductions: typing 
the NULL as DECIMAL changes ISNULL(?, 'fallback') from returning fallback to 
error 8114; a logical decimal NULL written into a DATE destination changes from 
success to a decimal/date type clash. The added tests protect both accepted 
legacy paths.
   
   ## Verification
   
   - Java 11, affected JDBC reactor spotless:apply + verify and 13 existing 
converter/builder tests passed.
   - JDBC E 2 E Part 3 package with its required reactor passed; unchanged 
seatunnel-engine-ui explicitly excluded. No UI changes or UI runtime claim.
   - The actual three added IT method bodies were compiled and replayed against 
an isolated real SQL Server 2019 CU 18 with the same driver, adapting only the 
existing database fixture and adding diagnostic printing. INSERT, native MERGE 
update and explicit UPDATE each preserved all 1,000 x 5 values, including scale 
38, high precision, negatives, NULL transitions and out-of-range logical NULL 
scales. Custom ISNULL and different/unknown target metadata retained their 
exact expected values.
   - The same performance regression assertion fails against baseline (1011 
server response packets for 10 batches, limit 80) and passes against the final 
converter (23 packets). A pre-target-metadata-guard candidate fails the DATE 
compatibility test, proving that regression test detects the unsafe 
implementation.
   - Both actual DataX Engine and SeaTunnelClient local mode ran on one Linux 
host over loopback JDBC. Same 1 GiB heap, same driver versions, one source 
split/writer, ordinary INSERT, batch 1000, commit perbatch, no checkpoint. 
Before each six-run stage:100,000-row warmups; then 3 alternating pairs of 
1,000,000 mixed-type rows. Every timed run was reconciled on primary key and 
all 19 typed fields; validation/preparation are outside timing.
   - The controlled candidate keeps the original engine/dependency JARs and 
overlays only the two changed module classes; its connector module classes 
match the standard Maven-packaged artifact. The unmodified baseline runtime is 
retained separately.
   
   Full Testcontainers bootstrap was not run locally: the Mac Docker API was 
unavailable, and the available old-kernel Linux host could not run the SQL 
Server 2022 image reliably. Real SQL 2019 JDBC regressions and actual-engine 
million-row jobs were run as above. GitHub CI must still validate the standard 
container lifecycle and current PR head; no CI pass or merge-readiness claim is 
made here.
   
   ## Final complete-job results
   
   These are process startup-to-exit elapsed times, measured with a monotonic 
clock. They are separate from the JDBC-component timings in the issue.
   
   | Round | DataX seconds | SeaTunnel candidate seconds | DataX/ST throughput 
ratio | Reconciliation |
   | --- | ---: | ---: | ---: | --- |
   | 1 | 61.665 | 55.467 | 0.899 x | 1,000,000 x 19 matched |
   | 2 | 51.607 | 56.847 | 1.102 x | 1,000,000 x 19 matched |
   | 3 | 51.598 | 55.976 | 1.085 x | 1,000,000 x 19 matched |
   
   All three final ratios are below 1.20; median paired ratio is 1.085 x, 
maximum 1.102 x. The slower first DataX control is retained, not removed; its 
single-round SeaTunnel lead is not treated as a stable win. Baseline SeaTunnel 
elapsed times were 89.478–91.714 s, final candidate 55.467–56.847 s, in 
separate stages under the same configuration.
   
   ## Related open work
   
   #10099 proposes direct SQL Server Bulk Copy, a different execution path; 
these tests keep ordinary JDBC batching. #10573 adds SQL Server tests and does 
not implement this NULL-scale fix. Open/closed PRs were checked for the same 
objective before implementation and again before submission; no duplicate was 
found. The Oracle-specific PR#13502 is independent and is not included in this 
branch.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to