zhengxiang378928908-code opened a new pull request, #11689:
URL: https://github.com/apache/seatunnel/pull/11689

   ### Purpose of this pull request
   
   Fixes #11688.
   
   `DmdbTypeConverter` has cases for `CHAR`, `CHARACTER`, `VARCHAR`, `VARCHAR2` 
and `NVARCHAR`, but no case for `NCHAR`. Reading a Dameng table containing 
`NCHAR` columns falls through to the `default` branch and fails:
   
   ```
   ErrorCode:[COMMON-17], ErrorDescription:['Dameng' unsupported convert type 
'nchar' of 'test' to SeaTunnel data type.]
   ```
   
   In a multi-table job the catalog aggregates these into `COMMON-21` and the 
whole job fails before any data is read.
   
   `NCHAR` is the fixed-length national character type and the counterpart of 
the already supported variable-length `NVARCHAR`. Supporting one but not the 
other looks like an oversight rather than an intentional restriction.
   
   **Length rule.** Every character type in this converter — `CHAR`, 
`CHARACTER`, `VARCHAR`, `VARCHAR2` and `NVARCHAR` — uses `charTo4ByteLength`. 
`NCHAR` follows the same rule, so the change introduces no new length behaviour 
and needs no assumption about how Dameng reports lengths. That matters here 
because Dameng's `LENGTH_IN_CHAR` parameter makes byte-vs-character length a 
database-level setting, so I deliberately avoided reasoning that depends on it.
   
   **Source type.** `NCHAR` gets its own case rather than joining the 
`CHAR`/`CHARACTER` branch, because that branch rewrites `sourceType` to the 
`CHAR` constant. Sharing it would report `NCHAR` columns as `CHAR(n)` and lose 
the national character type name.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, in the sense that a previously failing configuration now works: Dameng 
tables containing `NCHAR` columns can now be read by the JDBC source, and those 
columns map to SeaTunnel `STRING`.
   
   No config option, default value, or existing type mapping changes. The added 
case is purely additive, so this is backward compatible.
   
   ### How was this patch tested?
   
   **Unit test.** Added `DmdbTypeConverterTest#testNchar`, mirroring the 
existing `testNvarchar`, asserting the mapped data type, column length and 
source type.
   
   ```
   ./mvnw test -pl seatunnel-connectors-v2/connector-jdbc 
-Dtest=DmdbTypeConverterTest
   Tests run: 35, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   Reverting only the `DmdbTypeConverter` change makes it fail with the 
reported error, confirming it is a genuine regression test:
   
   ```
   [ERROR] testNchar  Time elapsed: 0.09 s  <<< ERROR!
   org.apache.seatunnel.common.exception.SeaTunnelRuntimeException: 
ErrorCode:[COMMON-17],
   ErrorDescription:['Dameng' unsupported convert type 'nchar' of 'test' to 
SeaTunnel data type.]
   ```
   
   **E2E test.** Added a `DM_NCHAR NCHAR(50)` column to `JdbcDmIT`, together 
with the matching `fieldNames` entry, row value and the explicit insert column 
list in `jdbc_dm_source_and_sink.conf`. The column is populated with multi-byte 
content so the national character path is exercised end to end. `JdbcDmUpsetIT` 
declares its own table and is unaffected.
   
   I could not run this suite locally — Docker is unavailable in my environment 
— so the `laglangyue/dmdb8` container path is validated by CI rather than by 
me. `./mvnw test-compile` on `connector-jdbc-e2e-part-5` passes, and the 
`CREATE_SQL` columns, `fieldNames`, row array, insert column list and 
placeholder count are all consistent at 34 entries.
   
   `./mvnw spotless:apply` was run over both modules.
   
   ### Note on overlap with #11684
   
   #11684 adds `NVARCHAR2` support and also touches `JdbcDmIT` and 
`jdbc_dm_source_and_sink.conf`. The converter changes sit in different branches 
of the switch and do not overlap, but the two PRs both extend the same E2E 
table, so whichever merges second will need a trivial rebase. I'm happy to 
rebase this one whenever #11684 lands — or to combine them if a maintainer 
would prefer a single PR covering the whole national character family.
   
   ### Check list
   
   * [x] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
 — no new dependency
   * [x] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs — not applicable, no 
option or documented behaviour changed
   * [x] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR — not applicable, change is backward 
compatible
   * [x] If you are contributing the connector code, please check that the 
following files are updated — not applicable, no new connector; E2E coverage 
added to the existing `JdbcDmIT`
   


-- 
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