You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "DanielLeens (via GitHub)" <gi...@apache.org> on 2026/04/20 06:55:57 UTC
Re: [PR] [Feature][Jdbc] Support shentong jdbc connector [seatunnel]
DanielLeens commented on PR #10340:
URL: https://github.com/apache/seatunnel/pull/10340#issuecomment-4278479583
Thanks for the contribution. I reviewed this PR locally from branch `seatunnel-review-10340` at commit `9445ffdbc5220b416fb146b74a839e50bac0c981`, against `upstream/dev` with merge base `81d873301d5d0bad16a3ef1680a3172d0968b8d9`.
This is a valuable addition: it wires Shentong/Oscar into the existing JDBC dialect/catalog extension model instead of adding special cases to the generic JDBC connector. The SPI path itself is reachable: the CI logs show the connector loading `OscarCatalog` and connecting to `jdbc:oscar://e2e_shentongdb:2003`.
## What this PR solves
- User pain point: users currently cannot use Oscar/Shentong through SeaTunnel JDBC with proper catalog/type/DDL/upsert behavior.
- Fix approach: the PR adds an Oscar dialect, catalog, type converter, DDL builder, row converter, docs, Maven wiring, unit tests, and E2E tests.
- In one sentence: this PR brings Oscar support to the JDBC connector, but two real runtime/test-path issues need to be fixed before merge.
Simple example: if an Oscar table contains an unconstrained `NUMBER` column, this PR correctly routes the table through the new Oscar type mapper, but the driver metadata currently becomes `precision=1000, scale=38`; the PR then creates `Decimal(1000, 38)`, which Spark/Flink cannot represent.
## Complete runtime path
```text
User submits an Oscar JDBC source/sink job
-> connector-jdbc is discovered
-> JdbcDialectLoader loads JdbcDialectFactory through ServiceLoader
-> OscarDialectFactory.acceptsURL("jdbc:oscar://...") returns true
-> JdbcSource / JdbcSink use OscarDialect
Source schema inference / catalog loading
-> OscarCatalog.getTable(...)
-> JDBC ResultSetMetaData is read
-> OscarTypeMapper.mappingColumn(metadata, colIndex) [OscarTypeMapper.java:35-52]
-> precision = metadata.getPrecision(colIndex)
-> scale = metadata.getScale(colIndex)
-> BasicTypeDefine stores precision/scale as-is
-> OscarTypeConverter.convert(typeDefine) [OscarTypeConverter.java:184-198]
-> NUMBER/NUMERIC/DECIMAL creates DecimalType(precision, scale)
-> if the Oscar driver reports NUMBER as precision=1000, scale=38
-> SeaTunnel schema contains Decimal(1000, 38)
-> Spark/Flink schema conversion
-> Spark fails because decimal precision must be <= 38
-> Flink has the same effective decimal precision boundary
Oscar upsert E2E
-> JdbcOscarUpsetIT.getJdbcCase()
-> database=OSRDB, schema=SYSDBA2 [JdbcOscarUpsetIT.java:57-60]
-> createNeededTables()
-> tables are created under SYSDBA2 [JdbcOscarUpsetIT.java:160-177]
-> AbstractJdbcIT.testJdbcDb() cleanup
-> clearTable(database, schema, sinkTable) [AbstractJdbcIT.java:382]
-> default clearTable(database, schema, table) calls clearTable(database, table) [AbstractJdbcIT.java:269-270]
-> cleanup targets OSRDB.E2E_TABLE_SINK_UPSET instead of SYSDBA2.E2E_TABLE_SINK_UPSET
-> the upsert E2E cannot reliably validate the Oscar MERGE path
```
## Findings
Issue 1: Oscar `NUMBER/NUMERIC/DECIMAL` can be mapped to an invalid `Decimal(1000,38)`
- Location: `seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oscar/OscarTypeMapper.java:39`; `seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oscar/OscarTypeConverter.java:188`
- Severity: High
- Description: this is on the normal Oscar source schema inference path. `OscarTypeMapper` stores the JDBC driver precision/scale as-is, and `OscarTypeConverter` directly creates `new DecimalType(precision, scale)`. In CI, `JdbcOscarIT.testJdbcDb` reached this path and produced `Decimal(1000,38)`, after which Spark failed with `decimal can only support precision up to 38`. This is not just a Spark-side issue; SeaTunnel’s cross-engine decimal contract needs to stay within the common precision boundary.
- Risk: an Oscar source table with unconstrained or driver-expanded `NUMBER/NUMERIC/DECIMAL` columns can fail deterministically during job startup/schema conversion. Retries will not help.
- Suggested fix: normalize Oscar decimal precision/scale in the Oscar type conversion layer. Cap precision at 38, ensure `scale <= precision`, and handle driver sentinel values such as `0` or `1000` with a documented default or conservative mapping. Please also add focused unit coverage for `NUMBER`, `NUMBER(p,s)`, `DECIMAL`, and `NUMERIC`, plus keep the E2E case that currently exposes this.
Issue 2: `JdbcOscarUpsetIT` creates tables in `SYSDBA2` but cleanup falls back to `OSRDB`
- Location: `seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-5/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcOscarUpsetIT.java:57`; `seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-5/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcOscarUpsetIT.java:160`; `seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-common/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/AbstractJdbcIT.java:269`
- Severity: Medium
- Description: `JdbcOscarUpsetIT` sets `database=OSRDB` and `schema=SYSDBA2`, then creates the tables under `SYSDBA2`. However, the inherited three-argument `clearTable(database, schema, table)` delegates to `clearTable(database, table)`, so cleanup targets `OSRDB.<table>`. `JdbcOscarIT` already overrides this to use the schema, but the upsert test does not.
- Risk: the new upsert E2E reports errors before it can reliably prove the Oscar `MERGE INTO` sink path. That makes the current CI result non-actionable for validating upsert support.
- Suggested fix: override `buildTableInfoWithSchema(String database, String schema, String table)` and `clearTable(String database, String schema, String table)` in `JdbcOscarUpsetIT`, following the same schema-first behavior already used by `JdbcOscarIT`.
## Compatibility
This PR is mostly compatible for existing users because it adds a new dialect and does not change existing JDBC APIs, config keys, defaults, protocols, or serialization formats. For the new Oscar path itself, the decimal behavior is not yet safe enough to become the first released behavior, so the precision/scale rule should be fixed before merge.
## Performance and side effects
The new dialect/catalog logic mainly runs during schema inference, DDL generation, and writer initialization, so I do not see a new hot-path CPU, memory, GC, network, or locking concern. The main deterministic failure is schema construction for invalid decimal precision. The upsert E2E issue is a test lifecycle/resource-cleanup problem, but it blocks confidence in the production upsert path.
## Error handling and logging
Current failures surface later than ideal: the decimal issue appears during Spark/Flink schema conversion rather than as an Oscar type-mapping error with column context, and the upsert E2E cleanup error can hide whether the actual `MERGE INTO` logic works. Fixing the conversion rule and namespace handling should make the error surface much clearer.
## Tests and docs
The PR adds meaningful unit tests and E2E coverage, which is good. The current CI shows that the new Oscar E2E path is catching a real issue. I also ran `git diff --check upstream/dev...HEAD`, and it reports blank lines at EOF in:
- `seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-5/src/test/resources/jdbc_oscar_source_and_oscar_upset_sink.conf:49`
- `seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-5/src/test/resources/jdbc_oscar_source_and_sink.conf:50`
The docs are updated in both English and Chinese. As a non-blocking follow-up, it would be helpful to also list Oscar/Shentong in the supported JDBC dialect/database list after the runtime issues are fixed.
## Merge conclusion
### Conclusion: can be merged after fixes
1. Blocking items that must be fixed
- Issue 1: normalize Oscar decimal precision/scale so normal source schema inference cannot produce `Decimal(1000,38)` or any decimal precision beyond the supported engine boundary.
- Issue 2: fix `JdbcOscarUpsetIT` namespace handling so the upsert E2E creates, writes, and cleans up the same schema/table path.
- The Build check is currently red. The PR-relevant `jdbc-connectors-it-part-5` job includes the decimal failure and the Oscar upsert cleanup errors above, so CI should be rerun after the fixes.
2. Suggested non-blocking improvements
- Clean up the two EOF whitespace issues reported by `git diff --check`.
- Add Oscar/Shentong to the JDBC supported dialect list in docs for easier user discovery.
Overall, this is a good and useful direction, especially for a first contribution touching a fairly large connector surface. The main structure is aligned with the existing JDBC architecture; the remaining work is to make the Oscar type boundary and E2E lifecycle stable. Once those two issues are fixed and CI is green, this should be in a much better shape for merge.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org