Repository navigation
[Fix][Translation][Spark] Carry DECIMAL with precision above 38 through Spark - #12862
zhengxiang378928908-code wants to merge 4 commits into
Conversation
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the contribution, @zhengxiang378928908-code, and for following the agreed design in #12814 so closely. I reviewed the full diff of head b0fed8a96 (16 files), the two row converters, TypeConverterUtils, MultiTableManager, the unit tests, the E2E configs and the en/zh docs.
What Problem Does This PR Solve?
- User pain point: on Spark 2.4 and 3.3, any SeaTunnel
DECIMAL(p > 38)(DorisLARGEINTasDECIMAL(39, 0), MySQLDECIMAL(65, x), PostgreSQLNUMERIC(50, 10)) fails at schema creation because Spark's decimal stops at 38. - Fix approach: carry top-level and
ROW-nested wide decimals as plain-textSTRINGwith precision/scale metadata and restoreDECIMAL(p, s)for transforms and sinks; reject wide decimals insideARRAY/MAPat job start. - One-sentence summary: lossless wide-decimal transport through Spark with explicit, early failure where it cannot be carried.
1. Code Change Review
1.1 Core Logic Analysis
CatalogTable -> MultiTableManager ctor
-> WideDecimalUtils.checkNoWideDecimalInCollection(tablePath, rowType) (before mergeSchema renames to column0..N)
-> TypeConverterUtils.convert(rowType)
wide DECIMAL -> StringType + metadata(seatunnel_decimal_precision/scale)
write: InternalRowConverter / SeaTunnelRowConverter.convert -> WideDecimalUtils.toCarrierText (setScale UNNECESSARY, toPlainString)
read : reconvert -> WideDecimalUtils.fromCarrierText (regex, exact scale, precision bound)
Before: TypeConverterUtils.convert built new org.apache.spark.sql.types.DecimalType(p, s) for any p, which Spark rejects for p > 38. After: only p > 38 takes the new path; p <= 38 keeps Decimal.apply(...) / the old default branch, so existing jobs are unaffected (isWideDecimal gates every new branch).
I traced the main user path: Spark source schema build -> MultiTableManager preflight -> row conversion on the source (InternalRowConverter.convert), transform (SeaTunnelRowConverter) and sink (InternalRowConverter.reconvert). The preflight is placed correctly so the table path and original column name survive. Rounding and overflow are rejected rather than applied, which keeps the data-correctness contract. I also confirmed the fall-through fix in InternalRowConverter.reconvert: before, a DECIMAL with an unexpected value type fell into the ARRAY branch (which threw an unrelated message); it now fails with a clear message.
1.2 Compatibility Impact
Fully compatible for existing jobs: schemas with p <= 38, and every non-decimal type, take the same code as before. Jobs with p > 38 failed at startup before, so nothing that worked changes. The only new restriction is the earlier, clearer failure for wide decimals in ARRAY/MAP, documented in incompatible-changes.md (en/zh). Note that Spark's own view of the data (Dataset schema, temp views) now shows STRING; this is documented.
1.3 Performance / Side-Effect Analysis
Narrow-only schemas pay a small extra cost: the recursive path argument adds a childPath() string concatenation per nested ROW field per row (InternalRowConverter convert/reconvert and SeaTunnelRowConverter), and TypeConverterUtils.convert(ROW/ARRAY/MAP) now also walks the type tree for the collection check each time it is called. InternalRowConverter.unpack already calls TypeConverterUtils.convert(fieldType) for every field of every row, so this walk is proportional to existing per-row work, but at the extreme-scale baseline (tens of billions of rows per task) avoidable per-row allocation is worth removing. See Issue 1.
1.4 Error Handling and Logging
Error codes SPARK-TRANSLATION-01/02/03 carry the table, column path, declared type and Spark limit, and the value is truncated to 64 characters in the message. Good.
Issue 1 (non-blocking, recommended): per-row string concatenation and type-tree walks on the hot path
- Location:
InternalRowConverter.javachildPath(...)calls inconvert(SeaTunnelRow, ...),reconvert(InternalRow, ...);SeaTunnelRowConverter.javaconvertRow/createFromGenericRow/reconvert;TypeConverterUtils.javacase ROW/ARRAY/MAPinconvert(SeaTunnelDataType). - Problem: the column path is built eagerly (
parent + "." + name) for every nestedROWfield of every row, although it is only needed when a wide decimal fails.checkNoWideDecimalInCollection/checkCollectionTypealso re-walk the type tree each timeconvert(dataType)is invoked, which happens per field per row inunpack. - Potential risk: extra garbage and CPU for every job with
ROWcolumns, including jobs that never use wide decimals. - Best improvement: pass the parent path and field name separately (or an index) and build the string only inside the error branch; and keep the collection check at schema-build time only (the preflight already covers it), for example by calling it from
MultiTableManager/theStructTypebuilder rather than from the per-rowconvert(dataType). - Severity: Medium
- Raised by another reviewer: No
Issue 2 (non-blocking): checklist wording
- Location: PR description, check list
- Problem: the item "Not a connector change" is left unchecked although this is a translation-layer change. Cosmetic.
- Potential risk: none.
- Best improvement: tick it or reword it.
- Severity: Low
- Raised by another reviewer: No
2. Code Quality Assessment
2.1 Coding Standards
License headers, class Javadoc and the error-code enum follow project conventions; the comments explain why the preflight runs before mergeSchema. Good.
2.2 Test Coverage and Test Stability
Strong. WideDecimalTest covers schema round trips, both converters (including RowEncoder), scale padding without rounding, rounding/overflow rejection, malformed carrier text, inconsistent metadata, ARRAY/MAP key/value/ROW-inside-array preflight, narrow decimals in collections still allowed, and the multi-table message naming the original table. The E2E (FakeSourceToAssertIT) uses the signed 128-bit extremes, zero, NULL, DECIMAL(50, 10), a narrow decimal beside them and a ROW, and asserts the SPARK-TRANSLATION-01 message on Spark for the MAP case. No existing test was weakened. Stability rating: Stable (deterministic inputs, no timing or fixed ports).
2.3 Documentation Updates
engines/spark.md, spark-translation-layer.md and incompatible-changes.md are updated in both docs/en and docs/zh with matching content and workarounds.
3. Architectural Soundness
The change stays inside seatunnel-translation-spark-common plus tests/docs, with no engine or API changes, and follows the boundaries agreed and accepted in #12814. Keeping the MySQL clamp out (#12841) is the right scope. The string carrier plus metadata mirrors how TIME/TIMESTAMP_TZ are already carried.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Eager column-path string building and repeated type-tree walks per row | InternalRowConverter, SeaTunnelRowConverter, TypeConverterUtils |
Medium (non-blocking) |
| 2 | Checklist item left unchecked | PR description | Low |
5. Merge Recommendation
CI for the current head b0fed8a96: labeler and Notify test workflow are green; Build is still in progress, so the Spark 2.4/3.3 E2E results for this head are not available yet (your fork run for the earlier commit reported them green). The branch is 17 commits behind dev with no conflicts, so no sync is required unless CI fails for an unrelated reason.
Conclusion: Ready to merge
-
Blockers — must be fixed
- None in code. Merge only after the
Buildjob on this head finishes green (the Spark E2E is the key evidence).
- None in code. Merge only after the
-
Recommended — non-blocking
- Issue 1 (hot-path overhead) and Issue 2 (checklist).
Review follow-up for apache#12862. - The row converters pass only the field name down. A nested ROW adds its name to InvalidWideDecimalException as the error passes through, so the column path is built only when a value fails, not for every nested field of every row. - TypeConverterUtils.convert no longer walks the type tree for the ARRAY/MAP check on every call. MultiTableManager still rejects these columns per table at job start; convert itself only carries an "inside a collection" flag through its own recursion as a safety net. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up for apache#12787. - incompatible-changes (en/zh): on Spark, top-level and ROW-nested LARGEINT is carried as text and restored to DECIMAL(39, 0); LARGEINT inside ARRAY/MAP now fails at job start with SPARK-TRANSLATION-01. Migration: leave those columns out with doris.read.field, or use Zeta or Flink. - DorisIT matches the error code, column path and table instead of the full message text of apache#12862. - spark/*.conf say they differ from the base job only in doris.read.field and must be kept in sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review, @DanielLeens. Both points are addressed in 36e16f4: Issue 1 (hot path)
Issue 2: ticked "Not a connector change" in the description. CI on my fork for the new head is running, and so is the combined run with #12787. I'll post both results here. |
DanielLeens
left a comment
There was a problem hiding this comment.
Thank you for the quick turnaround, @zhengxiang378928908-code, and for addressing both points from my previous round. I re-reviewed the whole current diff at head 36e16f44f (the incremental change over b0fed8a96 touches InternalRowConverter, SeaTunnelRowConverter, TypeConverterUtils, WideDecimalUtils and WideDecimalTest).
What Problem Does This PR Solve?
- User pain point: on Spark 2.4 and 3.3, any SeaTunnel
DECIMAL(p > 38)(for example DorisLARGEINTasDECIMAL(39, 0), MySQLDECIMAL(65, x)) fails at schema creation because Spark decimals stop at precision 38. - Fix approach: carry top-level and
ROW-nested wide decimals as plain-textSTRINGwith precision/scale metadata, restoreDECIMAL(p, s)for transforms and sinks, and reject wide decimals insideARRAY/MAPat job start. - One-sentence summary: lossless wide-decimal transport through Spark with early, explicit failure where it cannot be carried.
1. Code Change Review
1.1 Core Logic Analysis
CatalogTable -> MultiTableManager ctor
-> WideDecimalUtils.checkNoWideDecimalInCollection(tablePath, rowType) (real check, once per table, before mergeSchema renames columns)
-> TypeConverterUtils.convert(rowType)
wide DECIMAL -> StringType + metadata(seatunnel_decimal_precision/scale)
ARRAY/MAP -> convert(child, "element"|"key"|"value") -> wide DECIMAL throws (safety net only)
per row: InternalRowConverter / SeaTunnelRowConverter pass only the field name down
value failure -> InvalidWideDecimalException -> each enclosing ROW calls withParent(name) while unwinding
What changed since my last review (Issue 1 from the previous round):
- Before:
childPath(parent, name)built a string for every nestedROWfield of every row, andconvert(dataType)re-walked the type tree for the collection check on each call. - After: no string is built on the success path (
InternalRowConverter.javaconvert/reconvertROW branches,SeaTunnelRowConverter.javaconvert/reconvert), the exception rebuilds the dotted path on the way up throughwithParent, andTypeConverterUtils.convertonly threads acollectionPartflag through its existing recursion (no second walk). The ROW branch passescollectionPartinto its fields, soARRAY<ROW<DECIMAL(39,0)>>andMAP<STRING, ARRAY<ROW<...>>>are still rejected; narrow decimals inside collections still pass.
Key findings:
- The hot-path concern is resolved. On the success path the only added per-row work is the
isWideDecimalcheck onDECIMALfields and a try/catch frame aroundROWconversion, which costs nothing unless an exception is thrown. - The normal user path (Spark source schema ->
MultiTableManagerpreflight -> source/transform/sink row conversion) reaches all changed logic, andp <= 38plus every non-decimal type keep the pre-existing code. withParentcorrectly handles the null parent (top-level, or inside a collection) by returning the same exception, and copies the original stack trace so debugging is not degraded.- The collection-error message produced by the safety net in
TypeConverterUtilsonly nameselement/key/value(no table); the user-facing message with table and full column still comes from theMultiTableManagerpreflight, which is the documented entry point. - The new test
valueErrorNamesFullPathOfDeeplyNestedColumnasserts the full pathouter.info.inner_bigfor both converters, and the extended collection test coversMAP<STRING, ARRAY<ROW<DECIMAL(39,0)>>>.
I found no new correctness problem in the refactor.
1.2 Compatibility Impact
Fully compatible. Jobs with p <= 38 and all non-decimal types take the same code as before; jobs with p > 38 failed at startup before this PR. The only new restriction (wide decimal inside ARRAY/MAP) is an earlier, clearer failure and is documented in incompatible-changes.md (en and zh).
1.3 Performance / Side-Effect Analysis
No per-row allocation or type-tree walk is added for jobs that never fail a wide-decimal value. Exception construction is on the failure path only. No new threads, locks or static state.
1.4 Error Handling and Logging
Error codes SPARK-TRANSLATION-01/02/03 carry table, column path, declared type and the Spark limit; values are truncated in messages. InvalidWideDecimalException is a SeaTunnelRuntimeException subclass with the same error code as before, so callers that match on the error code are unaffected. No blocking issues.
Issue 1 (non-blocking, Low): withParent rebuilds the exception through a second constructor call
- Location:
WideDecimalUtils.javaInvalidWideDecimalException.withParent - Problem: the message is re-formatted at every nesting level, and the
(column == null ? parent : parent + "." + column)logic relies on a null column for the unnamed case. It works and is covered by the deep-nesting test; just be aware the cost is proportional to nesting depth on failure only. - Risk: none on the success path.
- Best improvement: optional; no change required.
- Severity: Low
- Raised by another reviewer: No
2. Code Quality Assessment
2.1 Coding Standards
License headers, Javadoc on the new exception and the collectionPart parameter explain the why. Good.
2.2 Test Coverage and Test Stability
Stability rating: Stable. WideDecimalTest (deterministic inputs, no timing, ports or static state) covers schema round trips, both converters, scale padding without rounding, rounding/overflow rejection, malformed carrier text, inconsistent metadata, collection preflight and the new deep-path assertions. The E2E (FakeSourceToAssertIT with the two wide-decimal configs) is unchanged since the last round. No existing test was weakened.
2.3 Documentation Updates
engines/spark.md, spark-translation-layer.md and incompatible-changes.md are updated in both docs/en and docs/zh, and the refactor does not change user-visible behavior, so no further doc change is needed.
3. Architectural Soundness
3.1 Elegance
Precise fix. The change stays within seatunnel-translation-spark-common, tests and docs.
3.2 Maintainability
Good: one preflight for the user-facing message, one safety net, and lazy path construction.
3.3 Extensibility
The carrier-text approach mirrors how TIME/TIMESTAMP_TZ are already carried and can be reused if Spark limits change.
3.4 Historical-Version Compatibility
No serialization, config or checkpoint format is touched; existing Spark jobs are unaffected.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | withParent re-formats the message per nesting level (informational) |
WideDecimalUtils.java |
Low |
5. Merge Recommendation
CI for head 36e16f44f: the apache-side labeler and Notify test workflow are green and Build is still in progress. In your fork run, License header, Dead links, Dependency licenses and unit-test (JDK 11/17 on ubuntu and windows) are green. The only failure so far is connector-sensorsdata-it (17), a connector IT in a module this PR does not touch, which looks unrelated; many other jobs are still queued or running, so the final result (in particular the Spark 2.4/3.3 E2E for FakeSourceToAssertIT) is not available yet. Branch state: 3 commits ahead, 17 behind dev, no conflicts; no sync is required unless CI fails for an unrelated reason.
Conclusion: Ready to merge
- Blockers - must be fixed
- None in code. Please wait for the
Buildjob on this head to finish green; the Spark E2E is the key evidence.
- None in code. Please wait for the
- Recommended - non-blocking
- None required; Issue 1 is informational.
Overall: the previous Medium finding is fully addressed with a clean design, and I have no remaining code-side concerns. Great work, and thanks again for the thorough tests and bilingual docs.
|
Update on the CI state for head The My source-side conclusion is unchanged and I have no remaining code concerns: the previous Medium finding was addressed, the change stays inside Nothing in this comment changes my earlier verdict (Ready to merge); the only item that was open on my side was the CI result, and it is now green. Thanks again for the thorough tests and bilingual docs. |
DanielLeens
left a comment
There was a problem hiding this comment.
Quick update on the CI status I cited in my previous review: Build was still pending on this head at that time and is now green. CI was the only remaining blocker in my last round (my conclusion was already "Ready to merge" with no code-side blockers), so I am changing my conclusion to approve. The non-blocking suggestions from my earlier review remain optional. Thanks again for the contribution!
davidzollo
left a comment
There was a problem hiding this comment.
Approving on top of the completed review from my earlier pass: no code-side blockers remain on this head, and Build is green. Thanks for the contribution and for the careful follow-through!
|
@davidzollo Thanks for the approval. This PR was removed from the merge queue at 16:15 UTC on October 21. Its merge-group run was created at 14:13 UTC, and its only job, Build, did not start until 19:33 UTC; it then passed (run 39615004850). The removal came about two hours after the run was created, which is consistent with the queue's 120-minute check timeout, although I could not see the removal reason directly. Could you add it to the queue again when you have a moment? |
|
Thanks for the queue details, @zhengxiang378928908-code. I checked the linked merge-group run: 39615004850 is now completed successfully. The current PR head remains There is no active auto-merge request in the current PR metadata, and the merge state is |
36e16f4 to
7b9d942
Compare
Review follow-up for apache#12862. - The row converters pass only the field name down. A nested ROW adds its name to InvalidWideDecimalException as the error passes through, so the column path is built only when a value fails, not for every nested field of every row. - TypeConverterUtils.convert no longer walks the type tree for the ARRAY/MAP check on every call. MultiTableManager still rejects these columns per table at job start; convert itself only carries an "inside a collection" flag through its own recursion as a safety net. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up for apache#12787. - incompatible-changes (en/zh): on Spark, top-level and ROW-nested LARGEINT is carried as text and restored to DECIMAL(39, 0); LARGEINT inside ARRAY/MAP now fails at job start with SPARK-TRANSLATION-01. Migration: leave those columns out with doris.read.field, or use Zeta or Flink. - DorisIT matches the error code, column path and table instead of the full message text of apache#12862. - spark/*.conf say they differ from the base job only in doris.read.field and must be kept in sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@davidzollo Your approval was dismissed when I rebased onto |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the rebase and the clear explanation, @zhengxiang378928908-code. I re-reviewed the new head 7b9d94255 from scratch and confirmed your statement: git range-diff against the approved head 36e16f44f shows commits 2 and 3 as identical (=), and commit 1 differs only in the context of the incompatible-changes.md hunk (en/zh), where your entry now sits after the new dev JSON-format entry and keeps it intact. No file under seatunnel-translation or connector-assert-e2e changed on dev between the old and the new base, so the code that was approved is also the code that will compile and run on the current base. The previous approval was dismissed only because of the rebase.
What Problem Does This PR Solve?
- User pain point: on Spark 2.4 and 3.3, any SeaTunnel
DECIMAL(p > 38)(DorisLARGEINTasDECIMAL(39, 0), MySQLDECIMAL(65, x)) fails at schema creation because Spark decimals stop at precision 38. - Fix approach: carry top-level and
ROW-nested wide decimals as plain-textSTRINGwithseatunnel_decimal_precision/seatunnel_decimal_scalemetadata, restoreDECIMAL(p, s)for transforms and sinks, and reject wide decimals insideARRAY/MAPat job start. - One-sentence summary: lossless wide-decimal transport through Spark with early, explicit failure where it cannot be carried.
1. Code Change Review
1.1 Core Logic Analysis
Changed files: WideDecimalUtils (new), TypeConverterUtils.convert, InternalRowConverter.convert/reconvert, SeaTunnelRowConverter.convert/reconvert, MultiTableManager (preflight), SparkTranslationErrorCode (new), unit and E2E tests, en/zh docs.
CatalogTable -> MultiTableManager ctor
-> WideDecimalUtils.checkNoWideDecimalInCollection(tablePath, rowType) once per table, before mergeSchema renames columns
-> TypeConverterUtils.convert(rowType)
DECIMAL p <= 38 -> Spark DecimalType (unchanged)
DECIMAL p > 38 -> StringType + precision/scale metadata
ARRAY/MAP child wide DECIMAL -> SPARK-TRANSLATION-01 (safety net)
per row (source / transform / sink):
toCarrierText: setScale(s, UNNECESSARY), precision check, toPlainString -> SPARK-TRANSLATION-02 on rounding/overflow
fromCarrierText: plain-decimal regex, exact scale, precision bound -> SPARK-TRANSLATION-02 on bad text
fromMetadata: both keys, STRING type, 38 < p, 0 <= s <= p -> SPARK-TRANSLATION-03
failure path only: InvalidWideDecimalException.withParent(...) builds the dotted column path while unwinding
Key findings on this head:
- The normal Spark user path (source schema build -> preflight -> source/transform/sink row conversion) reaches every changed branch, and
isWideDecimalgates all of them, sop <= 38and all non-decimal types keep the pre-existing code. - No value is ever rounded or narrowed silently:
RoundingMode.UNNECESSARYplus the precision check on write, and the exact-scale check on read. - The success path adds no per-row string building or type-tree walk (my earlier Medium item is still resolved on this head).
1.2 Compatibility Impact
Fully compatible. Jobs with p <= 38 and all non-decimal types are unaffected; jobs with p > 38 failed at startup before this PR. The only new restriction (wide decimal inside ARRAY/MAP) is an earlier, clearer failure and is documented in incompatible-changes.md (en and zh). No config option, serialization format or checkpoint state is touched.
1.3 Performance / Side-Effect Analysis
On the success path the only added per-row work is the isWideDecimal check on DECIMAL fields and a try/catch frame around ROW conversion. Exception construction happens only on failure. No new threads, locks or static mutable state.
1.4 Error Handling and Logging
Error codes SPARK-TRANSLATION-01/02/03 carry the table, column path, declared type and the Spark limit; values in messages are truncated to 64 characters. No formal issue on this head. The informational Low item from my previous round (withParent re-formats the message per nesting level, failure path only) still applies and needs no change.
2. Code Quality Assessment
2.1 Coding Standards
License headers, class Javadoc on WideDecimalUtils and InvalidWideDecimalException, and comments explaining why the preflight runs before mergeSchema are present.
2.2 Test Coverage and Test Stability
WideDecimalTest covers schema round trips, both converters (including RowEncoder), scale padding without rounding, rounding/overflow rejection, malformed carrier text, inconsistent metadata, ARRAY/MAP key/value preflight, the deep-path error message, and the multi-table message naming the original table. Removing the UNNECESSARY rounding mode, the preflight or the metadata validation turns these red. FakeSourceToAssertIT runs both wide-decimal configs on every engine and checks exact digits and scale in the sink. Stability rating: Stable (deterministic inputs, no sleeps, ports or shared static state).
2.3 Documentation Updates
engines/spark.md, spark-translation-layer.md and incompatible-changes.md are updated in both docs/en and docs/zh; the rebased entry content is unchanged.
Coordination note (non-blocking): #12853 (MySQL DECIMAL(p > 38) mapping, the follow-up you scoped out as #12841) adds an incompatible-changes.md entry at the same place and currently says wide decimals can fail during Spark schema translation. Whichever of the two PRs merges second will need a small conflict resolution there, and once this PR lands that sentence in #12853 should point to the new Spark behavior instead.
3. Architectural Soundness
3.1 Elegance
Precise fix, contained in seatunnel-translation-spark-common, tests and docs.
3.2 Maintainability
One preflight for the user-facing message, one safety net in TypeConverterUtils, and lazy path construction.
3.3 Extensibility
The string-carrier-plus-metadata approach mirrors existing carriers and can be reused if Spark limits change.
3.4 Historical-Version Compatibility
No serialization, config or checkpoint format is changed; existing Spark jobs keep the same types.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| - | No open issues on this head (previous informational Low item unchanged, no action needed) | - | - |
5. Merge Recommendation
CI for head 7b9d94255: the apache-side checks have not reported yet. The real Build run in your fork (run 40073956878) is in progress with 47 jobs green, 11 skipped and none failed so far; the Spark E2E results for this head are still pending. The branch is 0 commits behind dev and has no conflicts.
Conclusion: Ready to merge
- Blockers - must be fixed
- None on the code side. The only remaining gate is CI:
Buildmust finish green on this head.
- None on the code side. The only remaining gate is CI:
- Recommended fixes - non-blocking
- None. Please keep an eye on the
incompatible-changes.mdoverlap with #12853 noted above.
- None. Please keep an eye on the
Overall assessment: No blocking issues found. The rebased head is the same change I approved earlier; residual risk is limited to the pending CI result. I will be happy to approve again once Build is green. Thanks again for the careful work and the thorough bilingual docs.
|
@DanielLeens The fork The first attempt failed only in Could you re-approve when you have a moment? @davidzollo, once it is approved, could you add it back to the merge queue? Thanks! |
|
Thanks for posting the exact-head rerun result and for keeping it separate from source changes. My previous review had no outstanding source blocker; I am not asking for another code change here. I could not independently re-read fork run 40073956878 in this pass because GitHub returned HTTP 502, so I am recording its success as your reported result rather than claiming a fresh independent run verification. The PR snapshot still has no required Build result attached. A write-capable maintainer should confirm/attach that result and refresh the effective approval before returning it to the merge queue. My READ-level comment cannot re-approve or add it to that queue. Please keep the current branch unchanged while that result is reconciled. |
|
Thanks for the clear CI write-up, @zhengxiang378928908-code. I confirmed that the fork My technical conclusion is unchanged from my last review: no open source-side blocker, and I am happy with this head. Since the rebase only resolved the |
|
Thanks for the clear write-up, @zhengxiang378928908-code, and for keeping the rebase separate from any source changes. Where things stand, based on this thread:
I have no further code asks. Re-approval and re-enqueueing need a write-capable committer; I can't do either from my side, so that step remains with the committers. Two small asks on your side:
Nice work on the wide-decimal handling and on documenting the |
|
@davidzollo Gentle ping: reviewers have no further asks on head |
|
Thanks for the ping and for asking before touching the branch, @zhengxiang378928908-code. My recommendation: go ahead and rebase now rather than waiting. A conflict with To keep the re-review as cheap as the last one, please do the same as you did for
As before, nothing on the source side is outstanding from my previous review, and I am not asking for any code change beyond the conflict resolution. Once the new head and its Build link are posted, I will re-read the range-diff and record the result here so a write-capable committer can re-approve and re-enqueue in one pass. |
|
Thanks for the discussion about approval versus rebasing. The latest conflict state below is authoritative; if conflicts are present, resolve them before the final approval/queue step, preserve both migration entries and post the resulting head and Build link. The range-diff summary suggested by @SEZ9 is useful evidence, but any new head still needs a complete re-review. My source clearance for the unchanged reviewed head is separate from a committer's approval and queue permissions. Gate snapshot (2026-10-28T16:03:09+00:00), head CI is green, but that does not remove the separate conflict gate below. My previous source conclusion and any independent source requests remain as recorded; no new effective approval or dismissal is performed by this clarification. Separately, GitHub reports merge conflicts with |
|
Thanks for the ping and for laying out both options, @zhengxiang378928908-code. Since GitHub reports a conflict with When you rebase:
I'll re-review the new head promptly once it is up. Thanks for your patience with the back-and-forth. |
Review follow-up for apache#12862. - The row converters pass only the field name down. A nested ROW adds its name to InvalidWideDecimalException as the error passes through, so the column path is built only when a value fails, not for every nested field of every row. - TypeConverterUtils.convert no longer walks the type tree for the ARRAY/MAP check on every call. MultiTableManager still rejects these columns per table at job start; convert itself only carries an "inside a collection" flag through its own recursion as a safety net. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7b9d942 to
1ce4e26
Compare
Review follow-up for apache#12787. - incompatible-changes (en/zh): on Spark, top-level and ROW-nested LARGEINT is carried as text and restored to DECIMAL(39, 0); LARGEINT inside ARRAY/MAP now fails at job start with SPARK-TRANSLATION-01. Migration: leave those columns out with doris.read.field, or use Zeta or Flink. - DorisIT matches the error code, column path and table instead of the full message text of apache#12862. - spark/*.conf say they differ from the base job only in doris.read.field and must be kept in sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for resolving the base conflict and preserving the migration entries. I re-read the full current 16-file diff and the Spark 2.4/3.3 source, transform-carrier and sink paths, rather than relying on the earlier range-diff clearance. No blocking issues found. The old conflict/CI snapshot is superseded by the exact-head facts below; effective re-approval and queueing still belong to a write-capable committer.
What Problem Does This PR Solve?
User pain point: Spark rejects a SeaTunnel decimal with precision above 38 while building its schema, before any source row can be read.
Fix approach: Carry top-level and ROW-nested wide decimals as plain text with precision/scale metadata, restore BigDecimal at SeaTunnel boundaries, and reject unsupported collection positions before reading.
One-sentence summary: The 39-digit integer 170141183460469231731687303715884105727 travels through Spark as text, then reaches the SeaTunnel sink as the same BigDecimal with scale zero.
Review report time: 2026-10-29T12:21:22.718759-04:00. Current head 1ce4e26cdbdcac4cf2d901c807463fe82cdf2822; base dev at 886a3ac6e59aad5e46755761cf9fb8ac2a6d3df9. Checks: Signal pull request update=SUCCESS; Build=IN_PROGRESS. Check references: Signal pull request update Build. Compare: diverged, ahead 3, behind 5; merge state blocked / BLOCKED.
1. Code Change Review
1.1 Core Logic Analysis
All 16 files were read. MultiTableManager.java:61-68 preflights each original CatalogTable before mergeSchema renames its columns. TypeConverterUtils.java:121-163 uses StringType plus metadata only for precision>38 and propagates the inside-collection flag through ROW recursion. WideDecimalUtils.java:77-108 checks both metadata keys, StringType, integer values and precision/scale constraints. The two row converters gate text transport on isWideDecimal and add parent paths only while unwinding a value failure. Source tables in Spark 2.4 SourceSupport:85/121 and Spark 3.3 SourceTable:73 create MultiTableManager; both versions of their data writer call reconvert at :69 before sinkWriter.write. Narrow-decimal unexpected values now fail explicitly in InternalRowConverter instead of falling through its switch, while valid narrow values retain Decimal/BigDecimal handling.
Before:
case DECIMAL:
return new org.apache.spark.sql.types.DecimalType(p, s); // p > 38 rejected
// Internal row values use Spark DecimalAfter:
if (isWideDecimal(type)) return DataTypes.StringType; // metadata keeps p,s
value.setScale(s, RoundingMode.UNNECESSARY).toPlainString();
// Read validates plain text, exact scale and precision before restoring BigDecimalKey Findings
- Ordinary source schema creation reaches the preflight and carrier logic in both supported Spark adapters.
- The feature repairs the previously unsupported wide-decimal path; narrow decimals and other valid types retain their representations.
- ARRAY/MAP descendants are rejected intentionally at startup, with a separate recursive conversion safety net.
- Success-path conversion avoids a second schema walk and avoids constructing dotted error paths per row.
- External Spark expressions can still view these fields as strings; the bilingual guide explicitly states that boundary.
Complete runtime path
Source CatalogTable -> Spark 2.4 SeaTunnelSourceSupport / Spark 3.3 SeaTunnelSourceTable
-> new MultiTableManager -> preflight original table/column names -> mergeSchema
-> getTableSchema -> TypeConverterUtils.parcel/convert
-> wide decimal StringType + precision/scale metadata
SourceReader -> InternalRowCollector -> InternalRowConverter -> UTF8String exact carrier
-> Spark Dataset / RowEncoder -> transform reconvert -> SeaTunnel BigDecimal
-> transform output SeaTunnelRowConverter -> GenericRow string carrier
-> Spark sink DataWriter -> MultiTableManager.reconvert -> sinkWriter.write(BigDecimal)
ARRAY/MAP anywhere above wide decimal -> SPARK-TRANSLATION-01 before source rows
Bad value -> -02 with lazy nested field path; malformed metadata -> -03
The effects depend on the entry and preconditions above. Recovery, batching and connector lifecycle retain their existing contracts unless explicitly described here; source inspection is not runtime proof.
1.2 Compatibility Impact
Fully compatible. Existing valid precision<=38 jobs, public API signatures, options/defaults and checkpoint formats stay unchanged. Precision>38 jobs previously failed schema creation; the new Spark-facing representation is StringType with reserved metadata keys. Unsupported collection positions now fail earlier and more clearly. Both incompatible-changes pages document the new capability/rejection, native Spark string view and source-query/Zeta/Flink workarounds. No automatic existing sink-table migration is performed.
1.3 Performance / Side-Effect Analysis
Wide decimal rows allocate their necessary plain-text carrier and parse BigDecimal on return; no double/float conversion or rounding is used. Added type-tree preflight runs once per table before merge, while per-row checks are constant per visited decimal field. Nested path concatenation/exception reconstruction occurs only on failure. No new connection, executor, lock, retry, networking, shared mutable state or resource-close contract is introduced. This does not establish a new checkpoint/exactly-once guarantee.
1.4 Error Handling and Logging
Codes SPARK-TRANSLATION-01/02/03 distinguish unsupported position, bad value and bad metadata. RoundingMode.UNNECESSARY and precision/scale checks prevent silent narrowing. Values in errors are limited to 64 characters; error text still contains a bounded sample of decimal business data, consistent with the explicit diagnostics contract. Exceptions propagate and do not falsely report success.
No blocking issues found.
2. Code Quality Assessment
2.1 Coding Standards
The complete changed-file set, imports and removed lines were inspected. ASF headers and utility/exception class documentation explain carrier metadata, validation, lifecycle placement and failure-only parent path assembly. The new conversion overloads document the column argument and collection sentinel. No wildcard import or dependency was added. Core boundaries are described rather than exposing a new connector-level option.
2.2 Test Coverage and Test Stability
Stability rating: Stable. seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/test/java/org/apache/seatunnel/translation/spark/utils/WideDecimalTest.java:105-445 uses fixed BigDecimals and local schemas/converters, including actual RowEncoder serialization, null/zero/signed limits, exact scale, overflow/rounding errors, malformed text/metadata and nested ARRAY/MAP paths. At :344-366 the multi-table test checks schema metadata and round-tripped values. No sleep, port, clock, global timezone mutation or inter-test ordering dependency is added. FakeSourceToAssertIT.java:73-96 executes fixed input configurations, verifies exact sink digits/types/scale and requires the specific Spark collection error, not just any failure. Existing E2E fixtures are extended and Assert verifies committed pipeline output rather than container readiness alone. Unit coverage does not replace real Spark-version E2E CI; no tests ran locally.
Local verification results: exact-head git fetch and isolated review branch seatunnel-review-12862-20261029 created; full git diff 886a3ac6e59aad5e46755761cf9fb8ac2a6d3df9...1ce4e26cdbdcac4cf2d901c807463fe82cdf2822 read (16 files); git diff --check passed; git show, rg and line-numbered source/caller/config/test reads used for the trace above. GitHub changed filenames are reconciled with this local diff before publication. No local compile, Maven verify, unit/IT/E2E, Docker, service or UI execution occurred, as required for this review task. No build/deployment artifact was reused; engine-ui was not built.
2.3 Documentation Updates
Both Spark engine guides, translation-layer guides and incompatible-changes pages are updated consistently. Workarounds act at the source because source schema creation precedes transforms; a later Sql transform cannot rescue unsupported source collection metadata. Preserve adjacent dev migration entries during any future conflict resolution. Coordinate overlapping migration text with #12853 without modifying unrelated source behavior here.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix.
3.2 Maintainability
Best change-location assessment: The shared Spark translation boundary is the right root-cause layer: the source/sink logical decimal should not be narrowed merely to satisfy Spark. A metadata-backed string carrier is the smallest reusable approach consistent with existing TIME/TIMESTAMP_TZ carriers. A wider collection protocol would be a separate, larger design and is intentionally rejected here.
3.3 Extensibility
Keep existing connector identities and contracts. Reuse the current boundary and regression fixtures; no shared-framework redesign or unrelated dependency is needed for the behavior reviewed here.
3.4 Historical-Version Compatibility
Existing valid precision<=38 jobs, public API signatures, options/defaults and checkpoint formats stay unchanged. Precision>38 jobs previously failed schema creation; the new Spark-facing representation is StringType with reserved metadata keys. Unsupported collection positions now fail earlier and more clearly. Both incompatible-changes pages document the new capability/rejection, native Spark string view and source-query/Zeta/Flink workarounds. No automatic existing sink-table migration is performed. This review does not claim an executed upgrade/recovery validation.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| - | No blocking issues found | Full changed scope | - |
Completeness check: full diff and affected entry/call chain, failure/resource paths, compatibility, tests and stability, bilingual docs, configuration/registration and current CI/merge gates were inspected before enumerating these findings. No additional finding is reserved for a later round on this version.
Community review reconciliation: @SEZ9 recorded no further source asks and correctly separated source clearance from committer approval/queue permissions. I agree after this independent complete re-review. The earlier davidzollo approval was dismissed and is not represented as Daniel approval. The author and SEZ9 conflict-resolution/recheck requests are acknowledged in this single consolidated review.
5. Merge Recommendation
Conclusion: Ready to merge after fixes
- Blockers — must be fixed: No code-side blocker found. Required current-head CI and effective maintainer review/merge gates must be satisfied.
- Recommended fixes — non-blocking: No additional unrelated redesign is requested.
Overall assessment: The shared Spark translation boundary is the right root-cause layer: the source/sink logical decimal should not be narrowed merely to satisfy Spark. A metadata-backed string carrier is the smallest reusable approach consistent with existing TIME/TIMESTAMP_TZ carriers. A wider collection protocol would be a separate, larger design and is intentionally rejected here. Current head 1ce4e26cdbdcac4cf2d901c807463fe82cdf2822; base dev at 886a3ac6e59aad5e46755761cf9fb8ac2a6d3df9. Checks: Signal pull request update=SUCCESS; Build=IN_PROGRESS. Check references: Signal pull request update Build. Compare: diverged, ahead 3, behind 5; merge state blocked / BLOCKED. Behind/diverged status alone is synchronization metadata and does not justify a sync-and-rerun instruction. Daniel has READ permission: this COMMENT is a technical conclusion, not an effective APPROVED event or dismissal of historical requested changes. A write-capable maintainer owns final approval/dismissal where required. The previous CI/conflict fact cited in the thread has changed: evaluate the current head/check/merge snapshot above rather than the old 7b9d942 run. No unrelated source patch or blind rerun is requested. Daniel can publish this technical COMMENT but cannot perform the write-capable approval/dismiss/queue step. Thanks again; happy to help with the focused next revision.
|
The CI fact cited in my latest review has changed: the in-progress Build has now failed. The real blocking job is unit-test (17, ubuntu-latest), run 40828465494/job 123297627304: PhysicalVertexTest setup reports Node failed to start with port-binding failures in the log; all-connectors-it-3 (11) is cancelled. My Spark decimal source clearance remains unchanged. Latest dev adds tests in PhysicalVertexTest but leaves the shared server startup fixture unchanged; candidate port fixes #13028/#13030 are still open. No merged fix for this startup failure is established, so a simple sync alone is not a verified cure. Rerun the failed/cancelled jobs first; do not add unrelated engine edits to this decimal PR. Checked 2026-10-29T17:13:10+00:00; head Comparison: base Daniel has READ repository permission. This is a discussion/CI clarification, not a new complete source review, an effective APPROVED event or dismissal of historical requested changes. A write-capable maintainer must perform any required final approval/dismissal. Thanks for keeping the follow-up focused. |
|
Thanks again. I need to correct the upstream status in my previous CI follow-up: #13030 is now merged as d2fc2079035, while #13028 closed without merging. My earlier statement that both were still open is obsolete. The blocking execution remains unit-test (17, ubuntu-latest), job 123297627304, with the previously inspected PhysicalVertexTest startup/port-binding failure; the cancelled connector shard is a separate unfinished gate. I read the merged #13030 patch: it changes HTTP-port allocation in OptionRulesApiTest and RestApiSubmitJobStartWithSavePointTest, not the failing PhysicalVertexTest fixture. That is a related shared-test improvement, not proof that this particular failed startup is cured by syncing. Please avoid unrelated Spark/engine patches in this decimal PR. After checking that no newer Build is active, rerun the failed job(s); if startup still fails, retain its new port/startup diagnostics for an exact attribution. My Spark decimal source clearance remains unchanged. This is an upstream/CI fact correction, not a new list of source findings or an effective maintainer approval. Checked 2026-11-01T11:27:02.063637+00:00; unchanged head |
|
Following up on the approval-versus-rebasing question. The head is unchanged at On CI: the blocking job remains unit-test (17, ubuntu-latest), run 40828465494 / job 123297627304, where Concrete asks:
The decimal source changes remain clear from my side. This is a CI/merge-gate clarification, not an effective approval; a write-capable maintainer will do the final approval once the gates are green or the remaining failure is confirmed unrelated. |
|
Quick status update for head The My source-side position is unchanged: the Spark decimal changes are clear from my side, and I am not asking for any code change. The PR currently shows This is based on reading the code and GitHub's check state; I did not run anything locally. |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks again, @zhengxiang378928908-code, for your patience on this one.
My last review of head 1ce4e26cdbdcac4cf2d901c807463fe82cdf2822 found no code-side blocker, and @SEZ9 also cleared the source changes; the only remaining gate was CI. The re-run of fork run 40828465494 completed successfully on this exact head, and the apache-side Build is SUCCESS. That clears the earlier unit-test (17, ubuntu-latest) / PhysicalVertexTest startup failure.
In my previous follow-up I only reported the green result. To make the status explicit: CI was previously the only remaining blocker and it is now green, so my conclusion changes to approve.
I only have read access, so this approval does not satisfy branch protection; merging still needs a committer's approval and the queue step. Please keep the branch unchanged until then so the approval and the Build stay bound to the same head.
…gh Spark Spark's DecimalType stops at precision 38, so any SeaTunnel DECIMAL(p > 38) failed at schema creation on Spark 2.4 and 3.3 (apache#12814). - Top-level fields and fields inside a ROW are carried as a Spark STRING with seatunnel_decimal_precision / seatunnel_decimal_scale metadata and plain decimal text, and restored to DECIMAL(p, s) for transforms and sinks. - DECIMAL(p > 38) inside an ARRAY or MAP is rejected at job start, per source table before the multi-table merge, with the table, the column path, the declared type, the Spark limit and the workarounds. - Values that need rounding or overflow on write, and malformed text, a wrong scale or too many digits on read, are rejected instead of being changed silently. - InternalRowConverter no longer falls through from DECIMAL into ARRAY for an unexpected value type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n the e2e test catalog_table_rule compares whole Column objects, and the columns produced by the Sql transform differ from the rule-built ones in columnLength and options on every engine. The field rules already check the value class, scale and exact digits at the sink. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up for apache#12862. - The row converters pass only the field name down. A nested ROW adds its name to InvalidWideDecimalException as the error passes through, so the column path is built only when a value fails, not for every nested field of every row. - TypeConverterUtils.convert no longer walks the type tree for the ARRAY/MAP check on every call. MultiTableManager still rejects these columns per table at job start; convert itself only carries an "inside a collection" flag through its own recursion as a safety net. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1ce4e26 to
87c65a8
Compare
|
I rebased onto Compared with @DanielLeens, could you take another look when you have a chance? Thanks for reviewing the previous version. |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the careful rebase and clear summary! I re-reviewed the full current head, including the conversion boundaries and E2E assertions. I still do not see a source-level blocker. The earlier approval/build result was tied to a different head, so current-head CI and a write-capable maintainer decision remain separate.
What problem does this PR solve?
User pain: Spark rejects a SeaTunnel DECIMAL with precision above 38 during schema construction, even when the source can supply the exact value.
Fix: Carry supported wide decimals as plain STRING plus precision/scale metadata and reconstruct BigDecimal at SeaTunnel boundaries; reject collection-contained wide decimals early.
In one sentence: Values such as the signed 128-bit maximum can cross Spark without losing digits. A DECIMAL(39,0) customer balance now reaches the sink intact, while an ARRAY of those decimals gets an explicit startup error and source-side workarounds.
1. Code changes
1.1 Core logic
Complete runtime path:
Spark 2.4 SeaTunnelSourceSupport / Spark 3.3 SeaTunnelSourceTable -> MultiTableManager constructor: check every original table before mergeSchema
-> getTableSchema -> TypeConverterUtils.parcel/convert: wide decimal StructField becomes STRING with precision and scale metadata
-> source reader -> InternalRowCollector.collect -> InternalRowConverter.convert: UNNECESSARY scale normalization -> UTF8String
-> Spark Dataset / RowEncoder -> MultiTableManager.reconvert or SeaTunnelRowConverter -> exact-scale BigDecimal
-> SeaTunnel transform -> SeaTunnelRowConverter.convert -> Spark rows -> sink writer reconvert -> original SeaTunnel decimal type
-> nested ROW recurses and prepends column path only on error; any ARRAY/MAP ancestor rejects at schema preflight
-> schema read-back validates both metadata keys, carrier type, precision and scale before reconstructing DecimalType
Key findings and correctness:
The normal source schema path really reaches the changed code before rows are read. MultiTableManager validates original names before multi-table merging replaces them with column0..N. Both internal and GenericRow converters now implement the same null-preserving text carrier; ordinary DECIMAL <=38 keeps its existing numeric representation. Write conversion pads scale without rounding and rejects precision overflow; read conversion rejects scientific notation, whitespace, wrong scale and excess precision instead of silently narrowing. Nested ROW paths are built only on exceptions, and the collection flag travels through existing type recursion rather than triggering another per-row schema walk.
Metadata is attached to each wide-decimal StructField, including nested ROW fields, and validated on read-back. ARRAY/MAP-contained values are explicitly unsupported rather than relying on metadata that cannot be attached to an element. This is a targeted Spark translation representation change, not a change to Doris or PostgreSQL source types. Zeta/Flink conversion paths are untouched. The current full diff was re-read despite the author reporting a context-only rebase; their local build/test result is their evidence, not an execution by Daniel.
Before:
return new org.apache.spark.sql.types.DecimalType(decimalType.getPrecision(), decimalType.getScale());
// precision > 38 fails at schema constructionAfter:
if (WideDecimalUtils.isWideDecimal(dataType)) {
if (collectionPart != null) throw WideDecimalUtils.collectionError(null, collectionPart, (DecimalType) dataType);
return DataTypes.StringType;
}
// StructField metadata preserves declared precision/scale.
// toCarrierText uses setScale(scale, RoundingMode.UNNECESSARY).Current CI and merge gate: The PR check rollup is empty and the fork Build query returned no runs for head 87c65a8. This does not prove fork Actions is disabled. Please run/link Build for this head so the maintainer can refresh approval and enqueue against the same SHA. Compare against dev is ahead 3 / behind 1, diverged; this is recorded metadata, not evidence that syncing again will fix an observed failure. No unrelated engine patch is requested.
1.2 Compatibility
Partially incompatible in the Spark-facing representation for previously unsupported precision >38: supported fields now appear as STRING to Spark-native SQL/views, with SeaTunnel metadata restoring the logical type. Existing <=38 decimal APIs/config/defaults remain unchanged, and no new production dependency is added. Unsupported collection paths and invalid values fail explicitly. Both migration documents explain the boundary and source-side workarounds; a downstream transform cannot repair an already rejected source schema.
1.3 Performance and side effects
Wide-decimal rows allocate decimal text/UTF8String and parse BigDecimal on the return boundary, an inherent cost of the exact carrier. Ordinary rows avoid building nested path strings. Preflight is schema-time; no new global lock, network request, retry loop or owned background resource is added. Values in diagnostics are capped at 64 characters; schema metadata errors contain metadata rather than credentials.
1.4 Errors, logging, and findings
No new source-level blocker found. Exceptions must still reach the existing job failure path; this review does not substitute for current-head CI.
I agree with @SEZ9's source clearance and acknowledge @davidzollo's earlier approval, which is now DISMISSED after rebasing and is not an approval of this head. The prior hot-path concern is resolved by field-name-only propagation and a single schema preflight. The author's current reply describes a changelog-context rebase and 21 passing module tests; I re-reviewed the complete current diff rather than treating that report as current-head CI. The old PhysicalVertexTest failure and later green Build belonged to earlier heads.
2. Code quality
2.1 Conventions
Reviewed all changed files for license, imports, naming, core-method and state-field comments. No additional convention blocker found.
2.2 Test coverage and stability
Stability rating: Stable. Read the complete WideDecimalTest and both new E2E configurations plus FakeSourceToAssertIT. Deterministic cases exercise min/max signed 128-bit values, zero/null, scaled DECIMAL(50,10), ordinary decimals, schema/row/RowEncoder round-trips, multi-table fields, malformed metadata/carriers, deep error paths and collection rejection. BigDecimal.equals checks scale as well as digits. E2E routes through Sql and Assert with exact field types/values; MAP failure checks an actual error code and column path. See seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/test/java/org/apache/seatunnel/translation/spark/utils/WideDecimalTest.java:148 and seatunnel-e2e/seatunnel-connector-v2-e2e/connector-assert-e2e/src/test/java/org/apache/seatunnel/e2e/connector/assertion/FakeSourceToAssertIT.java:84. No fixed sleep, clock-dependent expected value or shared mutable fixture was added. Spark-version and real-container execution still need current-head CI.
2.3 Documentation
English and Chinese engine, architecture and incompatible-changes pages agree on metadata keys, exact-value rules, collection limitations and migration. The two rebased changelog hunks retain the preceding Iceberg entry. The docs distinguish Spark STRING views from SeaTunnel DECIMAL types.
3. Architecture
3.1 Change location
The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.
3.2 Maintainability
Keep the behavior, lifecycle ownership, and failure contract together. The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.
3.3 Extensibility
Prefer the existing component boundary and tests over unrelated shared abstractions.
3.4 Upgrade impact
Partially incompatible in the Spark-facing representation for previously unsupported precision >38: supported fields now appear as STRING to Spark-native SQL/views, with SeaTunnel metadata restoring the logical type. Existing <=38 decimal APIs/config/defaults remain unchanged, and no new production dependency is added. Unsupported collection paths and invalid values fail explicitly. Both migration documents explain the boundary and source-side workarounds; a downstream transform cannot repair an already rejected source schema.
4. Findings summary
Completeness check: All changed files and affected entry/failure paths were reviewed; configuration/serialization compatibility, test failure capability and stability, documentation/examples, change ownership, and current CI/conflict/review gates are covered above. No unreviewed source scope is claimed complete.
| # | Finding | Location | Severity |
|---|---|---|---|
| - | No new source blocker found | - | - |
5. Merge recommendation
Can merge once the recorded CI and repository gates are satisfied
Blocking items: No source blocker. Current-head CI and write-capable maintainer review remain independent requirements.
Non-blocking suggestions: None beyond the validation limits above.
Overall: the reviewed source path is coherent; no runtime acceptance is claimed beyond the actual CI result. Daniel has READ permission, so this COMMENT cannot dismiss historical requested changes or satisfy a write-capable maintainer approval gate.
CI and repository state: no check reported in the Apache rollup; no exact-head fork Build established. GitHub reports BLOCKED / REVIEW_REQUIRED.
Verification: Reviewed all changed files and the referenced call sites at 87c65a8591dba63d3a4ee17b0f8bb4786b717c37 against merge base a76348f1f98953444fd030fbbc56209d8ad40d18. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.
Review time: 2026-11-23T09:51:23.754233-05:00
Local evidence: git fetch obtained head 87c65a8591dba63d3a4ee17b0f8bb4786b717c37; git merge-base returned a76348f1f98953444fd030fbbc56209d8ad40d18; git diff --stat reports 16 files changed, 1348 insertions(+), 22 deletions(-). git show and source searches were used for the entry points above. No local build, unit test, E2E, Docker run or service startup was executed.
SEZ9
left a comment
There was a problem hiding this comment.
Thanks for working on this. I reviewed the latest head 87c65a8591db.
What this PR fixes
- User pain: on Spark 2.4/3.3 any SeaTunnel
DECIMAL(p > 38)column (for example PostgreSQLNUMERIC(50, 10), or DorisLARGEINTonce #12787 declares it asDECIMAL(39, 0)) failed at schema creation withdecimal can only support precision up to 38, before any row was read. - Fix approach:
TypeConverterUtilsmaps a wide decimal toStringType(TypeConverterUtils.java:119-127) and storesseatunnel_decimal_precision/seatunnel_decimal_scalein the field metadata (:153-154).InternalRowConverterandSeaTunnelRowConverterwrite the value withWideDecimalUtils.toCarrierTextand read it withfromCarrierText. Both apply strict scale and precision checks and fail with SPARK-TRANSLATION-02 instead of rounding.MultiTableManagerrejects wide decimals insideARRAY/MAPper source table beforemergeSchema(MultiTableManager.java:63-67), so SPARK-TRANSLATION-01 names the real table and column path.
- Coverage:
WideDecimalTestcovers the schema carrier, both converters and the preflight.FakeSourceToAssertITadds two assert configs (fake_wide_decimal_to_assert.conf,fake_wide_decimal_map_to_assert.conf). - Assessment: the design is sound. The findings below concern unbounded work on hostile values, error-message quality in multi-table jobs, documentation that runs ahead of the Doris connector, and a few consistency gaps between the two converters.
Runtime chain I rechecked
Job start - schema + preflight
SeaTunnelSourceTable (spark-3.3) SeaTunnelSourceTable.java:73 / SeaTunnelSourceSupport (spark-2.4) SeaTunnelSourceSupport.java:86,132
(also sinks: SeaTunnelSinkTable.java:91, SeaTunnelSparkDataWriterFactory.java:83, SparkDataWriterFactory.java:82; transforms: TransformExecuteProcessor.java:176,178)
-> new MultiTableManager(catalogTables) MultiTableManager.java:61
-> WideDecimalUtils.checkNoWideDecimalInCollection(tablePath, rowType) per source table MultiTableManager.java:63-67
-> WideDecimalUtils.check(...) recursion; ARRAY/MAP set inCollection=true WideDecimalUtils.java:124-156
-> collectionError(...) => SPARK-TRANSLATION-01 with table + column path WideDecimalUtils.java:207-221
-> mergeSchema(catalogTables) (renames to column0..N when >1 table) MultiTableManager.java:68, :140-188
-> multi-table: new InternalRowConverter / SeaTunnelRowConverter(mergeCatalogTable.getSeaTunnelRowType(), indexes) MultiTableManager.java:81-83, :94-96
-> single table: converters on catalogTables[0].getSeaTunnelRowType() MultiTableManager.java:98-100
-> getTableSchema() MultiTableManager.java:136-138
-> TypeConverterUtils.parcel(...) TypeConverterUtils.java:169-180
-> convert(SeaTunnelRowType, collectionPart): wide DECIMAL -> StringType (:119-127) + precision/scale metadata (:153-154)
Per row - SeaTunnel -> Spark
InternalRowConverter.convert -> parcel InternalRowConverter.java:190-216
-> convert(field, type, column), DECIMAL branch InternalRowConverter.java:128-134
-> WideDecimalUtils.toCarrierText (setScale UNNECESSARY, precision check, toPlainString) WideDecimalUtils.java:159-178
SeaTunnelRowConverter.convert -> parcel SeaTunnelRowConverter.java:74-91
-> convert(field, type, column), DECIMAL branch SeaTunnelRowConverter.java:114-119 -> toCarrierText
Per row - Spark -> SeaTunnel
InternalRowConverter.reconvert -> unpack InternalRowConverter.java:295-312
-> reconvert(field, type, column), DECIMAL branch InternalRowConverter.java:375-388
-> WideDecimalUtils.fromCarrierText (plain-text pattern, exact scale, precision) WideDecimalUtils.java:181-201
SeaTunnelRowConverter.reconvert -> unpack SeaTunnelRowConverter.java:221-238
-> reconvert(field, type, column), DECIMAL branch SeaTunnelRowConverter.java:263-269 -> fromCarrierText
Value errors
invalidValue(...) -> InvalidWideDecimalException => SPARK-TRANSLATION-02 WideDecimalUtils.java:223-226, :241-277
each enclosing ROW adds its name with withParent(column) WideDecimalUtils.java:264-276
Schema read-back (no caller in src/main)
TypeConverterUtils.convert(DataType) TypeConverterUtils.java:182-205
-> convert(StructType) TypeConverterUtils.java:231-256
-> WideDecimalUtils.fromMetadata => SPARK-TRANSLATION-03 on inconsistent metadata WideDecimalUtils.java:77-109
Findings
Issue 1: toCarrierText expands the value with setScale and toPlainString before any bound check, so one record with an extreme exponent (e.g. 1E+100000000) can exhaust executor CPU and heap instead of failing cleanly with SPARK-TRANSLATION-02.
- Location:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:162 - Why it matters: Root cause:
toCarrierTextcallsvalue.setScale(decimalType.getScale(), RoundingMode.UNNECESSARY)first and only afterwards checksscaled.precision() > decimalType.getPrecision(). Both rejection paths then callvalue.toPlainString(), andabbreviatetrims the result to 64 characters only after the full string exists. - Large negative scale: for
new BigDecimal("1E+100000000")intoDECIMAL(39, 0),setScale(0, ...)has to materialise 10^100000000 as aBigInteger(roughly 40 MB). The precision check then fails, andtoPlainString()builds a string of about 100 million characters. - Large positive scale: for
1E-100000000,setScaleneeds the same power of ten for the division and throwsArithmeticException. Thecatchblock then callstoPlainString(), which again expands to about 100 million characters.
Impact: if a source hands over a BigDecimal with such an exponent (for example one parsed from untrusted text), a single row can stall or OOM the executor. The job then dies with an unrelated error rather than the intended SPARK-TRANSLATION-02.
Suggested fix:
-
Reject on cheap properties before expanding: compare the integer digit count (
value.precision() - value.scale()) withp - s, and the fraction digits afterstripTrailingZeros()withs. CallsetScaleonly once both fit. -
Build the message from a bounded rendering such as
value.toString()(scientific notation) passed throughabbreviate, not fromtoPlainString(). -
Add a unit test with
1E+100000000and1E-100000000that expects SPARK-TRANSLATION-02. -
Evidence:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:167 value.toPlainString(),;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:170 if (scaled.precision() > decimalType.getPrecision()) {;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:174 value.toPlainString(), -
Suggested fix:
setScaleruns before the precision check, and both rejection paths callvalue.toPlainString(). For aBigDecimalwith an extreme exponent this expands the number before we reject it. -
new BigDecimal("1E+100000000"):setScale(0, UNNECESSARY)builds 10^100000000 as aBigInteger, andtoPlainString()then allocates a string of about 100 million characters thatabbreviatetrims only afterwards. -
1E-100000000:setScalethrows, and thecatchblock callstoPlainString()with the same expansion.
One such row can stall or OOM the executor instead of failing with SPARK-TRANSLATION-02.
Could we reject on cheap properties first: value.precision() - value.scale() against p - s, and the fraction digits after stripTrailingZeros() against s? setScale would then run only when both fit. The message could use a bounded form such as value.toString() passed through abbreviate. A unit test with these two inputs would pin it down.
- Priority: P1 — should fix in this PR
- I traced this in the code.
- When it happens: Spark job whose source schema declares
amount DECIMAL(39, 0)and reads JSON (e.g. Kafka with json format). One record:{"amount":"1E+100000000"}.new BigDecimal("1E+100000000")has unscaled value 1 and scale -100000000. IntoCarrierText,setScale(0, UNNECESSARY)materialises 10^100000000, thentoPlainString()allocates a 100,000,001-character string, of which 64 characters are kept. The task spends that CPU and several hundred MB of heap before SPARK-TRANSLATION-02 is thrown (or it dies with OutOfMemoryError on a small executor), and Spark's task retries repeat it.
Issue 2: In multi-table Spark jobs, SPARK-TRANSLATION-02 names the merged placeholder columnN and no table, so the user cannot tell which source column held the bad value.
- Location:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/InternalRowConverter.java:200 - Why it matters: Root cause:
- The value converters take the column name from the row type they were built with. For more than one table,
MultiTableManagerbuilds both converters onmergeCatalogTable.getSeaTunnelRowType()(MultiTableManager.java:81-83and:94-96), whose fieldsmergeSchemarenamed tocolumn0..N. - So
rowType.getFieldName(indexes[i])inInternalRowConverter.parcel/unpackandSeaTunnelRowConverter.parcel/unpackyieldscolumn3, not the source column. InvalidWideDecimalExceptioncarries only the column, the declared type, the value and the reason. It has no table.
Impact:
- A rejected value reports
Column `column3` declared as DECIMAL(39, 0): value '...' is rejected because .... - Merged columns are shared between tables by type, so the placeholder does not identify a table or a column.
- This is the problem the PR avoids for SPARK-TRANSLATION-01 by running the preflight before
mergeSchema. The value error does not get the same treatment.
Suggested fix:
- The source table and its field names are available where the converters are created, through
columnWithIndex.getCatalogTable(). Give the multi-table converters the table path and the source field names, or the source row type alongside the index mapping. - Use them for the top-level
columnargument and include the table in the message. - Add a multi-table case to
WideDecimalTestthat asserts the real table and column in SPARK-TRANSLATION-02. - Evidence:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/InternalRowConverter.java:306 rowType.getFieldName(indexes[i]));;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/SeaTunnelRowConverter.java:85 rowType.getFieldName(indexes[i]));;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/SeaTunnelRowConverter.java:232 rowType.getFieldName(fieldIndex)); - Suggested fix: In the multi-table branch
MultiTableManagerbuilds this converter onmergeCatalogTable.getSeaTunnelRowType(), sorowType.getFieldName(indexes[i])is the merged placeholder (column0..N), not the source column. A rejected value then reportsColumn `column3` declared as DECIMAL(39, 0)with no table. That is the problem the preflight avoids for SPARK-TRANSLATION-01 by running beforemergeSchema.
The source table is available where the converters are created (columnWithIndex.getCatalogTable()). Could we pass the table path and the source field names into the multi-table converters and use them here and in unpack? The same applies to SeaTunnelRowConverter.parcel / unpack. A multi-table test asserting the real table and column for SPARK-TRANSLATION-02 would be good to have.
- Priority: P1 — should fix in this PR
- I traced this in the code.
- When it happens: Spark job with two source tables:
demo.a(id INT, amount DECIMAL(39, 0))anddemo.b(id INT, total DECIMAL(50, 10)). A row ofdemo.acarries a 40-digitamount.InternalMultiRowCollectorpicks thedemo.aconverter,parcelcallsconvert(value, DECIMAL(39,0), "column1"), and the job fails withColumn `column1` declared as DECIMAL(39, 0): value '...' is rejected because it has more than 39 digits.Neitheramountnordemo.aappears.
Issue 3: engines/spark.md (en and zh) presents Doris LARGEINT as DECIMAL(39, 0) and the incompatible-changes note calls DECIMAL(20, 0) the "old" type, but on this head the Doris connector still declares LARGEINT as DECIMAL(20, 0).
- Location:
docs/en/engines/spark.md:145 - Why it matters: - Root cause: the wording assumes #12787 is merged. On this head
AbstractDorisTypeConverter.java:190still doesdecimalType = new DecimalType(20, 0)forDORIS_LARGEINT, andDorisTypeConverterV2.java:172still buildsnew DecimalArrayType(new DecimalType(20, 0))forARRAY<largeint>. - Impact: a Doris user reading
engines/spark.md(en and zh) will expectLARGEINTcolumns to take the new STRING-carrier path andARRAY<LARGEINT>to fail withSPARK-TRANSLATION-01. With this PR alone neither happens.LARGEINTremains a normal SparkDECIMAL(20, 0), and the overflow above 20 digits that the incompatible-changes note attributes to the "old" type is still the current behaviour. - The incompatible-changes entry is phrased conditionally ("If the Doris source declares
LARGEINTasDECIMAL(39, 0)"). CallingDECIMAL(20, 0)"old" in the same sentence still reads as if the change has already shipped. - Suggested fix: lead with an example that holds on this head, such as PostgreSQL
NUMERIC(50, 10). Either move the Doris-specific wording into #12787, or make it explicitly conditional on that change in all four places (en/zhengines/spark.md, en/zhincompatible-changes.md). - Evidence:
docs/en/introduction/concepts/incompatible-changes.md:166 If the Doris source declaresLARGEINTasDECIMAL(39, 0), this applies to DorisARRAYcolumns andLARGEINTmap keys and values on Spark, which could overflow above 20 digits with the oldDECIMAL(20, 0)type.;docs/zh/engines/spark.md:138 Spark 的DECIMAL类型精度最大为 38,而 SeaTunnel 的类型可以更宽,例如 DorisLARGEINT(DECIMAL(39, 0))或 PostgreSQLNUMERIC(50, 10)。 - Suggested fix: On this head the Doris connector still declares
LARGEINTasDECIMAL(20, 0)(AbstractDorisTypeConverter.java:190, andDorisTypeConverterV2.java:172forARRAY<largeint>), so this example is not true until #12787 lands.
Could we lead with the PostgreSQL NUMERIC(50, 10) example, which holds today, and either move the Doris wording into #12787 or make it explicitly conditional here?
The same applies to the zh page and to the incompatible-changes note, which calls DECIMAL(20, 0) the "old" type although it is still the current one.
- Priority: P2 — optional
- I traced this in the code.
- When it happens: Read a Doris table with a
LARGEINTcolumn and anARRAY<LARGEINT>column on Spark at this head. The SeaTunnel type isDECIMAL(20, 0), so the Spark schema isDecimalType(20,0), not the STRING carrier, and the array column does not fail with SPARK-TRANSLATION-01. That contradicts whatengines/spark.mdleads the reader to expect.
Issue 4: SPARK-TRANSLATION-02 embeds the rejected column value in the exception message, and the 64-character cap leaves typical values intact (a DECIMAL(39, 0) value is at most 40 characters), so the value reaches Spark's logs and UI.
- Location:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:255 - Why it matters: Root cause:
InvalidWideDecimalExceptionformatsvalue '%s'into its message, andabbreviatetruncates only aboveMAX_VALUE_LENGTH_IN_MESSAGE = 64. - A value that fits
DECIMAL(39, 0)is at most 40 characters and one that fitsNUMERIC(50, 10)at most 52, so values of that size are emitted in full. Longer ones still expose their first 64 characters. - On the read path the raw carrier
textis echoed. That is whatever string sits in the Spark column, not necessarily a number.
Impact: the exception is thrown inside a Spark task, so its message is surfaced wherever Spark reports task failures: executor and driver logs and the failure reason in the UI. Those places are usually readable by a wider audience than the source table. For columns such as account identifiers or balances this is a data exposure.
Suggested fix:
- Keep the value out of the message by default. Report what the user needs to act on instead: the column, the declared type, and the observed digit count or scale. The
reasontext already carries most of this. - If the value is useful for debugging, log it at DEBUG or put it behind an explicit opt-in.
- Evidence:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:255 "Column%sdeclared as %s: value '%s' is rejected because %s.",;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:225 return new InvalidWideDecimalException(column, decimalType, abbreviate(value), reason);;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:183 throw invalidValue(column, decimalType, text, "it is not plain decimal text"); - Suggested fix: This message carries the rejected value itself. The 64-character cap does not truncate typical values (a
DECIMAL(39, 0)value is at most 40 characters), so the whole value is emitted. On the read path it is the raw carrier text, whatever that string is.
Because the exception is thrown inside a task, Spark surfaces it in executor and driver logs and in the failure reason in the UI. Those are usually readable by more people than the source table.
Could we drop the value from the message and report the column, the declared type and the observed digit count or scale instead? The reason already says which rule failed. If the value is needed for debugging, DEBUG logging or an explicit opt-in would be safer.
- Priority: P2 — optional
- I traced this in the code.
- When it happens: Column
balance DECIMAL(39, 0), source value12345678901234567890123456789012345678901(41 digits).toCarrierTextfails at:170and the task dies withColumn `balance` declared as DECIMAL(39, 0): value '12345678901234567890123456789012345678901' is rejected because it has more than 39 digits.The complete value is in the Spark task-failure message.
Issue 5: The two converters handle an unexpected Spark value for a wide DECIMAL differently, and the new IllegalArgumentException drops the column name it has in scope.
- Location:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/SeaTunnelRowConverter.java:269 - Why it matters: The PR states that values are never changed silently, but the two read paths disagree on a value that is not carrier text.
SeaTunnelRowConverter.reconvert(theGenericRowpath used by transforms) falls back toreturn field;when the type is wide and the value is neitherStringnorUTF8String. Whatever object is in the row reaches the transform or sink typed asDECIMAL(p, s)with no validation.InternalRowConverter.reconvertis stricter. It acceptsDecimalandBigDecimalas before, and throws for any other class. That is the right behaviour.- The exception it throws is a plain
IllegalArgumentException("Unexpected Spark value of type %s for SeaTunnel %s"). It omits thecolumnparameter that the method already has and carries noSPARK-TRANSLATIONcode.
Impact: a type mismatch on the GenericRow path passes through unnoticed and fails later, far from the cause. On the InternalRow path the error does not say which column was affected.
Suggested fix:
- In
SeaTunnelRowConverter.reconvert, fail in the wide branch when the value is not text. UseINVALID_WIDE_DECIMAL_VALUEwith the column and the value class. - In
InternalRowConverter.reconvert, addcolumnto the message, and preferably use the same error code so both paths report the problem the same way. - Evidence:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/InternalRowConverter.java:385 throw new IllegalArgumentException(;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/InternalRowConverter.java:387 "Unexpected Spark value of type %s for SeaTunnel %s", - Suggested fix: For a wide decimal whose value is neither
StringnorUTF8String, thisreturn field;hands the raw object to the transform or sink asDECIMAL(p, s)without any check.InternalRowConverter.reconvertthrows for an unexpected value class in the same position.
Since the PR's contract is no silent changes, could the wide branch fail here too, with INVALID_WIDE_DECIMAL_VALUE, the column, and the value class?
The new IllegalArgumentException in InternalRowConverter.reconvert has column in scope but does not include it. Adding it there, ideally with the same error code, would make both paths report this consistently.
- Priority: P2 — optional
- I traced this in the code.
- When it happens: Row type
{big: DECIMAL(39, 0)}.new SeaTunnelRowConverter(rowType).reconvert(new GenericRow(new Object[]{(byte) 0, "db.t", new BigDecimal("1.5")}))returns a row whosebigis1.5(scale 1), unvalidated, while the text"1.5"in the same position is rejected with SPARK-TRANSLATION-02 ("its scale is 1, expected 0"). On the InternalRow path, a value of an unexpected class in a DECIMAL column fails withUnexpected Spark value of type java.lang.String for SeaTunnel ..., with no column name.
Issue 6: The schema read-back (fromMetadata, SPARK-TRANSLATION-03) has no production caller, yet the design doc lists it as a rule of the data path.
- Location:
docs/en/architecture/api-design/spark-translation-layer.md:119 - Why it matters: Root cause:
WideDecimalUtils.fromMetadatais called only from the privateTypeConverterUtils.convert(StructType), which is reached only through the publicconvert(DataType sparkType).- A search of all
src/maincode forTypeConverterUtils.convert(finds only SeaTunnel-to-Spark calls, all inInternalRowConverter.MultiTableManager.getTableSchemagoes throughparcel, which is also SeaTunnel-to-Spark. The Spark starter does not call it. Nothing in production converts a Spark schema back to a SeaTunnel type. - Row values are restored from the SeaTunnel row type held by the converters. The doc itself says so in the sentence after the rule list: "Row values are converted from the SeaTunnel row type".
Impact: the doc bullet reads as if the metadata round trip and SPARK-TRANSLATION-03 protect running jobs. In practice they are exercised only by WideDecimalTest. A reader may rely on a check that never runs, for example after a transform changes the field metadata.
Suggested fix: state in the bullet (en and zh) that the read-back is a utility for callers that convert a Spark schema back and is not used by the job path today. Alternatively, drop fromMetadata and error code 03 until a caller exists.
- Evidence:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/TypeConverterUtils.java:238 DecimalType wideDecimalType = WideDecimalUtils.fromMetadata(structFields[i]);;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:77 public static DecimalType fromMetadata(StructField field) {;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/exception/SparkTranslationErrorCode.java:31 "SPARK-TRANSLATION-03", "Invalid SeaTunnel decimal metadata on a Spark schema field"); - Suggested fix: I looked for a production caller of this read-back and found none. Every
TypeConverterUtils.convert(...)call insrc/maingoes SeaTunnel-to-Spark, and the starter does not use it. SofromMetadataand SPARK-TRANSLATION-03 are exercised only byWideDecimalTest, and the job path restores the type from the SeaTunnel row type, as the last sentence of this section says.
Could this bullet say that the read-back is a utility that the job path does not use today, so readers do not assume the metadata is validated at runtime? The zh page needs the same change. If no caller is planned, dropping fromMetadata and code 03 until one exists is also an option.
- Priority: P2 — optional
- I traced this in the code.
- When it happens: Run any Spark job with a top-level
DECIMAL(39, 0)column, e.g.fake_wide_decimal_to_assert.conf.MultiTableManager.getTableSchema()writesseatunnel_decimal_precision/seatunnel_decimal_scaleviaparcel, and values are restored from the SeaTunnel row type held by the converters.TypeConverterUtils.convert(DataType)is never invoked, so stripping or corrupting the metadata on the Dataset can never produce SPARK-TRANSLATION-03, although the doc reads as if it would.
Issue 7: The fallback guard in TypeConverterUtils reports only element/key/value as the column, with no table, real column name or nested ROW field.
- Location:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/TypeConverterUtils.java:123 - Why it matters: The Javadoc says this guard "only keeps other callers safe", but the error it raises is not actionable.
- Root cause:
collectionError(null, collectionPart, ...)is called with the literal part name, so the message readsColumn `element` has type DECIMAL(39, 0) inside an ARRAY/MAP. - For
ARRAY<ROW<amount DECIMAL(39, 0)>>, the ROW branch forwards the samecollectionPartto its fields, so the nested field nameamountis lost as well. - Impact: this is not reachable through the job path today. The only schema entry in
src/mainisparcelviaMultiTableManager.getTableSchema, which runs after the preflight in theMultiTableManagerconstructor. Any other caller ofTypeConverterUtils.convert(...), including tests and future code, gets a message that does not identify the column. - Suggested fix: carry a field path through the recursion instead of the bare part name, in the same
col.element/col.value.amountform thatWideDecimalUtils.checkbuilds. If that is not wanted, the message should at least say that the table and column are unknown at this point. - Evidence:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/TypeConverterUtils.java:123 null, collectionPart, (DecimalType) dataType);;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/TypeConverterUtils.java:132 return convert((SeaTunnelRowType) dataType, collectionPart); - Suggested fix: This fallback produces
Column `element` has type DECIMAL(39, 0) inside an ARRAY/MAP, with no table, no real column, and no nested field name forARRAY<ROW<...>>(the ROW branch forwards the samecollectionPart).
It is not reachable in production today because MultiTableManager rejects first, but as the safety net for other callers it should be actionable.
Could we carry the field path through the recursion instead of the bare part name, in the same col.element / col.value.amount form that WideDecimalUtils.check builds? If not, the message could at least say that the table and column are unknown here.
- Priority: P2 — optional
- I traced this in the code.
- When it happens: Call
TypeConverterUtils.convert(new SeaTunnelRowType(new String[]{"items"}, new SeaTunnelDataType<?>[]{new ArrayType<>(SeaTunnelRow[].class, new SeaTunnelRowType(new String[]{"amount"}, new SeaTunnelDataType<?>[]{new DecimalType(39, 0)}))})). It throws SPARK-TRANSLATION-01 withColumn `element` has type DECIMAL(39, 0) inside an ARRAY/MAP. Neitheritemsnoramountnor a table appears. TheMultiTableManagerpreflight reportsitems.element.amountand the table for the same type.
Issue 8: Public entry points and the metadata key constants in WideDecimalUtils have no Javadoc, although the keys become part of the Spark schema that users can see.
- Location:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:49 - Why it matters: - Root cause:
isWideDecimalis public and called fromTypeConverterUtils,InternalRowConverterandSeaTunnelRowConverter. It has no Javadoc.metadatais public and has no Javadoc.PRECISION_KEYandSCALE_KEYare public constants and are undocumented.toCarrierTextandfromCarrierTexthave a one-line description. They do not say whatcolumnmay be (nullinside an ARRAY or MAP, per the converters' own Javadoc) or that they throwInvalidWideDecimalException.
- Impact:
seatunnel_decimal_precisionandseatunnel_decimal_scaleare written intoStructFieldmetadata and are visible in the Dataset schema. Nothing in the code marks them as a stable contract or states that both are stored as long. - Suggested fix:
- Add a short Javadoc on the two keys saying they are part of the Spark schema and stored as long.
- Add one line each on
isWideDecimalandmetadata. - Add
@param columnand@throwsontoCarrierText/fromCarrierText.
- Evidence:
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:60 public static boolean isWideDecimal(SeaTunnelDataType<?> dataType) {;seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/utils/WideDecimalUtils.java:65 public static Metadata metadata(DecimalType decimalType) { - Suggested fix: Small nit: these two keys end up in the Spark
StructFieldmetadata and are visible in the Dataset schema, so they are effectively a stable contract. Could we add a short Javadoc saying so, and that both are stored as long?
The public isWideDecimal and metadata below would benefit from a line each. toCarrierText / fromCarrierText could document the column parameter (which may be null) and the thrown InvalidWideDecimalException.
- Priority: P2 — optional
- I traced this in the code.
- When it happens: Open
WideDecimalUtils.javaat lines 48-50, 60 and 65: there is no Javadoc on any of them. Renamingseatunnel_decimal_precisionthere changes the metadata on every wide-decimal column of the Spark Dataset schema, and nothing in the code marks the name as a stable contract.
Review conclusion
Conclusion: final approval remains pending on the previous comments
2. Remaining follow-ups
- Issue 1:
toCarrierTextexpands the value withsetScaleandtoPlainStringbefore any bound check, so one record with an extreme exponent (e.g.1E+100000000) can exhaust executor CPU and heap instead of failing cleanly with SPARK-TRANSLATION-02. - Issue 2: In multi-table Spark jobs, SPARK-TRANSLATION-02 names the merged placeholder
columnNand no table, so the user cannot tell which source column held the bad value. - Issue 3:
engines/spark.md(en and zh) presents DorisLARGEINTasDECIMAL(39, 0)and the incompatible-changes note callsDECIMAL(20, 0)the "old" type, but on this head the Doris connector still declaresLARGEINTasDECIMAL(20, 0). - Issue 4: SPARK-TRANSLATION-02 embeds the rejected column value in the exception message, and the 64-character cap leaves typical values intact (a
DECIMAL(39, 0)value is at most 40 characters), so the value reaches Spark's logs and UI. - Issue 5: The two converters handle an unexpected Spark value for a wide DECIMAL differently, and the new
IllegalArgumentExceptiondrops the column name it has in scope. - Issue 6: The schema read-back (
fromMetadata, SPARK-TRANSLATION-03) has no production caller, yet the design doc lists it as a rule of the data path. - Issue 7: The fallback guard in
TypeConverterUtilsreports onlyelement/key/valueas the column, with no table, real column name or nested ROW field. - Issue 8: Public entry points and the metadata key constants in
WideDecimalUtilshave no Javadoc, although the keys become part of the Spark schema that users can see.
Thanks for the updates so far. Happy to discuss the remaining points.
|
Thanks, @SEZ9, for the detailed evidence. This is a substantive clarification of the unchanged head, and I should narrow my earlier clean-conclusion wording rather than imply these points were all disproved.
These are your existing findings, not a second numbered Daniel review. The documentation correction and the requested bounded-rejection/validation follow-up remain open for the author/maintainer to resolve; I cannot treat the earlier unconditional source-clear statement as final acceptance. No exact-head CI run/check is currently attached, and absence alone does not prove Actions are disabled. Please attach the real Build/PR-signal reference when it is started. This is a discussion follow-up on unchanged head |
… errors Review follow-up for apache#12862. - toCarrierText checks the integer digits (in long arithmetic) and the length of the resulting text before anything is rendered, so a value such as 1E+100000000 is rejected without being expanded, and a long value that would need rounding fails a cheap trailing-zero check first. - fromCarrierText rejects text longer than 3 + p + |s| before it is matched or parsed (UTF8String by its byte length, before decoding), and counts the digits of the unscaled value before BigDecimal parses it. The writer never emits leading zeros, so valid carrier text always fits. - Negative scales (PostgreSQL 15 NUMERIC(p, -s)) are written as plain integers and read back exactly: the trailing zeros are checked in the text and only the digits before them are parsed, without a division. - SPARK-TRANSLATION-02 no longer includes the rejected value. It names the source table and column; in a multi-table job the converters map the merged columnN back to the source column name, even if it has a dot. - Both converters accept only String/UTF8String for a wide decimal and reject anything else with SPARK-TRANSLATION-02. The non-wide fallback error now names the column. - The TypeConverterUtils fallback for ARRAY/MAP names the full field path, built only when the conversion fails, so the per-row path allocates nothing extra. - fromMetadata rejects a null precision or scale instead of reading it as 0, and its error no longer serializes the metadata. - Javadoc for the public constants and entry points. - Docs: use PostgreSQL NUMERIC(50, 10) as the example (Doris LARGEINT is still DECIMAL(20, 0) on this head), describe fromMetadata as a utility that the job path does not call, state the read rules precisely, and note that errors omit the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… errors Review follow-up for apache#12862. - toCarrierText checks the integer digits (in long arithmetic) and the length of the resulting text before anything is rendered, so a value such as 1E+100000000 is rejected without being expanded, and a long value that would need rounding fails a cheap trailing-zero check first. - fromCarrierText rejects text longer than 3 + p + |s| before it is matched or parsed (UTF8String by its byte length, before decoding), and counts the digits of the unscaled value before BigDecimal parses it. The writer never emits leading zeros, so valid carrier text always fits. - Negative scales (PostgreSQL 15 NUMERIC(p, -s)) are written as plain integers and read back exactly: the trailing zeros are checked in the text and only the digits before them are parsed, without a division. - SPARK-TRANSLATION-02 no longer includes the rejected value. It names the source table and column; in a multi-table job the converters map the merged columnN back to the source column name, even if it has a dot. - Both converters accept only String/UTF8String for a wide decimal and reject anything else with SPARK-TRANSLATION-02. The non-wide fallback error now names the column. - The TypeConverterUtils fallback for ARRAY/MAP names the full field path, built only when the conversion fails, so the per-row path allocates nothing extra. - fromMetadata rejects a null precision or scale instead of reading it as 0, and its error no longer serializes the metadata. - Javadoc for the public constants and entry points. - Docs: use PostgreSQL NUMERIC(50, 10) as the example (Doris LARGEINT is still DECIMAL(20, 0) on this head), describe fromMetadata as a utility that the job path does not call, state the read rules precisely, and note that errors omit the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9299f45 to
a0162f4
Compare
|
Thanks, @SEZ9, for the detailed review, and @DanielLeens for the follow-up. Pushed
Also in this push: wide decimals with a negative scale (PostgreSQL 15+ Verification: with Spotless, the Spark translation common module builds and About CI: I can't attach a fork run for this head. Actions on my fork has not run since 2026-11-05. Dispatching |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for addressing the detailed feedback and for contributing to Apache SeaTunnel. I re-reviewed the entire new head, including the negative-scale and bounded-rejection paths. The eight previously acknowledged findings are addressed in the code/docs, so Daniel's source-level blockers are cleared. The actual current Build has now appeared and failed during wrapper setup; the specific next step is below, replacing the older missing-CI guidance.
What problem does this PR solve?
User pain: Spark rejects SeaTunnel DECIMAL precision above 38 during schema construction, before reading even a valid PostgreSQL NUMERIC(50,10) row.
Fix: Carry supported wide decimal fields as plain text with precision/scale metadata and restore exact BigDecimal values at SeaTunnel boundaries; fail early for wide decimals inside ARRAY/MAP.
One sentence: Preserve wide decimal digits through Spark while explicitly rejecting unsupported shapes and invalid values.
Example: A top-level NUMERIC(50,10) balance becomes STRING inside Spark and returns to the sink as the same BigDecimal and scale; a MAP value of DECIMAL(39,0) fails at source-schema setup with its real field path.
1. Code changes
1.1 Core logic
Complete runtime path:
Spark2.4 SeaTunnelSourceSupport:86/132 or Spark3.3 SeaTunnelSourceTable:73
-> MultiTableManager constructor -> each original CatalogTable preflight before mergeSchema
-> reject ARRAY/MAP descendants with real table/column (SPARK-TRANSLATION-01)
-> build source-aware converters and merged index mappings -> getTableSchema/TypeConverterUtils.parcel
-> wide top-level/ROW field: StringType + long precision/scale metadata
SeaTunnel source row -> InternalRowConverter.parcel -> toCarrierText -> UTF8String
Transform boundary -> SeaTunnelRowConverter -> String/GenericRow -> Spark RowEncoder -> reverse converter
Spark internal/generic row -> fromSparkValue -> length check -> plain-text/scale/digit validation
-> exact BigDecimal, including negative scale -> original RowKind/tableId -> transform or sink
Value failure -> InvalidWideDecimalException -> nested ROW withParent -> root withSource
-> original table/field plus type/reason; no rejected value in message
Separate schema-readback utility -> TypeConverterUtils.convert(DataType StructType)
-> fromMetadata -> validate both long keys/type/range; not the normal job restoration path
Key findings and correctness:
- Read all 16 changed files, both value converters and all 31 added UT methods/fixtures. The normal Spark schema and per-row translation boundaries reach this code. Wide collections fail before any transform, so a downstream Sql cast cannot bypass source-schema construction.
- @SEZ9's eight existing findings are closed in the current implementation: pre-expansion digit/text bounds, source-table attribution, qualified Doris examples, omitted raw values, shared strict non-text rejection, honest metadata-utility scope, fallback field paths, and public metadata/method contracts. These are not repeated under new Daniel issue numbers.
- toCarrierText checks integer digits before setScale, handles zero separately, caps rendered length, and rejects impossible dropped digits using precision/lowest-set-bit bounds before division. It retains UNNECESSARY rounding enforcement. The extreme positive/negative exponent cases are rejected without their exponent expansion; already large unscaled inputs still have processing proportional to their input size.
- fromCarrierText bounds length before regex/parse, checks exact fraction count and unscaled significant digits, and restores negative scale by checking trailing zeros then parsing only the remaining digits. UTF8String byte length is checked before decoding. Both converters preserve null before calling the utility and reject non-text carriers with SPARK-TRANSLATION-02. Ordinary DECIMAL <=38 keeps its existing route; its unexpected-type error gains a field name.
- SourceFieldNames are indexed by source position while indexes map into merged schema slots. Nested ROW errors add parents on unwind and withSource replaces the whole root, including dotted source names, so columnN no longer leaks into normal multi-table value diagnostics. Collection preflight remains source-aware; the utility fallback explicitly says the table is unknown.
- This is a transport representation, not native Spark decimal arithmetic above precision 38. Spark Dataset/views see strings, and ARRAY/MAP support is deliberately excluded. Row values are restored from the retained SeaTunnel row type; metadata readback is separately validated but not falsely described as a normal runtime guard.
- The new exact-head fork Build exists and has failed, so the older no-run/Actions-disabled statement is no longer the current gate. The failed transform-v2-it-part-2 JDK11 lane received repeated HTTP429 downloading the Maven wrapper JAR and then MavenWrapperMain was missing, before tests. Three other lanes were cancelled. Latest fetched dev still has the same wrapper URLs; its unrelated lane-timeout adjustments do not fix this download failure. Please rerun that lane and the cancelled lanes after confirming no newer run is active, and obtain required upstream check adoption from a maintainer. No unrelated Spark or dependency patch is justified by this log.
Before:
case DECIMAL:
DecimalType decimalType = (DecimalType) dataType;
return new org.apache.spark.sql.types.DecimalType(
decimalType.getPrecision(), decimalType.getScale());After:
if (WideDecimalUtils.isWideDecimal(dataType)) {
if (inCollection) {
throw new WideDecimalInCollection(null, (DecimalType) dataType);
}
return DataTypes.StringType;
}1.2 Compatibility
Partially incompatible Spark-visible representation and fail-fast behavior, documented in EN/ZH incompatible-changes: formerly failing wide top-level/ROW columns can run as STRING carriers; invalid precision/scale and unsupported collections fail explicitly. Existing public converter constructors remain and delegate to the source-context overload; configuration keys/defaults, SeaTunnel row types and checkpoint formats are not renamed. Spark-native consumers must account for STRING schema/view fields; collection workarounds must act at the source or use Zeta/Flink. This PR alone does not change Doris LARGEINT from DECIMAL(20,0). No new dependency.
1.3 Performance and side effects
Valid wide values require plain-text allocation and exact BigDecimal conversion, adding CPU/heap versus native narrow decimal; metadata/preflight occur at schema setup. Extreme exponents are bounded before expansion, UTF8 bytes before decode and carrier digits before BigDecimal parse. The documented maximum text length is a representability guard, not a small executor memory quota; exceptionally huge declared types remain expensive and no throughput/memory bound beyond the code is claimed. Error paths allocate nested contextual exceptions without storing or logging raw values. No new network, lock, asynchronous retry or persistent resource owner.
1.4 Errors, logging, and findings
No new source-level blocker found. Exceptions must still reach the existing job failure path; this review does not substitute for current-head CI.
+1 to @SEZ9's eight-point review: the current changes address each concern with the paths and tests described above. The older davidzollo approval is DISMISSED and referred to a previous head; I do not treat it as current approval or as Daniel's action. The author's direct explanation is answered in this one full rereview. Source clearance is distinct from current CI and write-capable maintainer approval/dismissal, including any historical changes-requested display.
2. Code quality
2.1 Conventions
Reviewed all changed files for license, imports, naming, core-method and state-field comments. No additional convention blocker found.
2.2 Test coverage and stability
Stability rating: Stable. Stable: fixed BigDecimal fixtures check exact value AND scale, nested ROWs, both InternalRow and GenericRow/RowEncoder boundaries, source-table mapping, collection descendants, malformed text, invalid metadata and null metadata. WideDecimalTest:430 and its later long-value case use generous five-second preemptive ceilings to catch pathological expansion, not sleeps or asynchronous result assumptions; bounded fixtures include 800k/1m-character inputs and their outcomes are deterministic. The E2E verifies exact field types/values through Sql and a one-row min/max assertion, and checks the specific startup error/path for Spark MAP while other engines must succeed. No added port/global singleton/clock-derived expected value or live database dependency in UT. No local UT/E2E execution; the author's build/test report remains their evidence.
2.3 Documentation
EN/ZH architecture, engine and migration pages agree on the supported positions, exact scale/precision rules, negative scale, STRING visibility, source-only collection workarounds and value-free errors. PostgreSQL NUMERIC is the current example; Doris behavior is explicitly unchanged until its separate connector change. fromMetadata is correctly described as utility-only. Stable precision/scale keys are documented as long metadata values.
3. Architecture
3.1 Change location
The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.
3.2 Maintainability
Keep the behavior, lifecycle ownership, and failure contract together. The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.
3.3 Extensibility
Prefer the existing component boundary and tests over unrelated shared abstractions.
3.4 Upgrade impact
Partially incompatible Spark-visible representation and fail-fast behavior, documented in EN/ZH incompatible-changes: formerly failing wide top-level/ROW columns can run as STRING carriers; invalid precision/scale and unsupported collections fail explicitly. Existing public converter constructors remain and delegate to the source-context overload; configuration keys/defaults, SeaTunnel row types and checkpoint formats are not renamed. Spark-native consumers must account for STRING schema/view fields; collection workarounds must act at the source or use Zeta/Flink. This PR alone does not change Doris LARGEINT from DECIMAL(20,0). No new dependency.
4. Findings summary
Completeness check: All changed files and affected entry/failure paths were reviewed; configuration/serialization compatibility, test failure capability and stability, documentation/examples, change ownership, and current CI/conflict/review gates are covered above. No unreviewed source scope is claimed complete.
| # | Finding | Location | Severity |
|---|---|---|---|
| - | No new source blocker found | - | - |
5. Merge recommendation
Can merge once the recorded CI and repository gates are satisfied
Blocking items: No source blocker. Current-head CI and write-capable maintainer review remain independent requirements.
Non-blocking suggestions: None beyond the validation limits above.
Overall: the reviewed source path is coherent; no runtime acceptance is claimed beyond the actual CI result. Daniel has READ permission, so this COMMENT cannot dismiss historical requested changes or satisfy a write-capable maintainer approval gate.
CI and repository state: no check reported in the Apache rollup; Build: failure. GitHub reports BLOCKED / REVIEW_REQUIRED.
Verification: Reviewed all changed files and the referenced call sites at a0162f497d5553d5b44936599d1bfb9cbf14c719 against merge base a76348f1f98953444fd030fbbc56209d8ad40d18. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.
Review time: 2026-11-26T08:56:34.438662-05:00
Local evidence: git fetch obtained head a0162f497d5553d5b44936599d1bfb9cbf14c719; git merge-base returned a76348f1f98953444fd030fbbc56209d8ad40d18; git diff --stat reports 16 files changed, 2111 insertions(+), 41 deletions(-). git show and source searches were used for the entry points above. No local build, unit test, E2E, Docker run or service startup was executed.
SEZ9
left a comment
There was a problem hiding this comment.
Thanks for the follow-up. I checked the latest changes at a0162f497d55 against my previous review comments.
The scope of this pass is limited to the findings from the previous review; it does not introduce a new set of review items.
What this PR fixes
This update addresses the eight points from the previous review in the Spark translation module and its docs. WideDecimalUtils now bounds its work before rejecting a value and no longer puts the value in the error message. Both row converters share one strict read path for wide decimals. Value errors in multi-table jobs name the source table and column. The docs no longer present Doris LARGEINT as a wide decimal on this head, and they describe fromMetadata as a schema read-back utility outside the job path. No new findings are raised in this re-review.
Runtime chain I rechecked
MultiTableManager constructor -> checkNoWideDecimalInCollection per source table (SPARK-TRANSLATION-01 with table and column path) -> InternalRowConverter / SeaTunnelRowConverter built with the source table path and source column names
Write: converter.convert -> WideDecimalUtils.toCarrierText (integer-digit, text-length and dropped-digit checks, then setScale and toPlainString) -> STRING carrier
Read: converter.reconvert -> WideDecimalUtils.fromSparkValue (String / UTF8String only, length bound first) -> fromCarrierText (pattern, fraction digits, digit count) -> BigDecimal at the declared scale
On a value error: InvalidWideDecimalException -> withParent for each enclosing ROW -> withSource(sourceTable, sourceColumn) in the top-level converter loop -> SPARK-TRANSLATION-02 without the value
Resolved previous findings
PR12862-F1toCarrierTextexpands the value withsetScaleandtoPlainStringbefore any bound check, so one record with an extreme exponent (e.g.1E+100000000) can exhaust executor CPU and heap instead of failing cleanly with SPARK-TRANSLATION-02.PR12862-F2In multi-table Spark jobs, SPARK-TRANSLATION-02 names the merged placeholdercolumnNand no table, so the user cannot tell which source column held the bad value.PR12862-F5SPARK-TRANSLATION-02 embeds the rejected column value in the exception message, and the 64-character cap leaves typical values intact (aDECIMAL(39, 0)value is at most 40 characters), so the value reaches Spark's logs and UI.PR12862-F6The two converters handle an unexpected Spark value for a wide DECIMAL differently, and the newIllegalArgumentExceptiondrops the column name it has in scope.PR12862-F7The schema read-back (fromMetadata, SPARK-TRANSLATION-03) has no production caller, yet the design doc lists it as a rule of the data path.PR12862-F3engines/spark.md(en and zh) presents DorisLARGEINTasDECIMAL(39, 0)and the incompatible-changes note callsDECIMAL(20, 0)the "old" type, but on this head the Doris connector still declaresLARGEINTasDECIMAL(20, 0).PR12862-F8The fallback guard inTypeConverterUtilsreports onlyelement/key/valueas the column, with no table, real column name or nested ROW field.PR12862-F9Public entry points and the metadata key constants inWideDecimalUtilshave no Javadoc, although the keys become part of the Spark schema that users can see.
Review conclusion
Conclusion: verification is incomplete; approval is not ready
Nice work — the previous concerns are addressed. Thanks again for the contribution.
|
Thanks, @SEZ9, for explicitly confirming that the eight earlier source/documentation findings are closed on this head; that agrees with my full source review. The remaining failed check is specifically transform-v2-it-part-2 / JDK 11: Maven-wrapper download returns HTTP 429, followed by MavenWrapperMain missing, before test execution. The latest dev wrapper is unchanged and the fallback proposal #13466 is still open, so I cannot recommend sync as a demonstrated fix. Once artifact access recovers, rerun that failed lane and share its new job URL if it repeats. Keep unrelated wrapper/dependency changes out of this Spark decimal PR; the current failure supplies no decimal-test result. This is a discussion/gate follow-up on unchanged head |
|
Thanks for the thorough follow-up on this PR. The eight points from the previous review are addressed on head
No new findings were raised in the re-review, so there are no further source or documentation asks from that list. The one thing still open is the failed Remaining asks:
|
Purpose of this pull request
Closes #12814. Unblocks #12787.
Spark's
DecimalTypestops at precision 38, so any SeaTunnelDECIMAL(p > 38)failed at schema creation on Spark 2.4 and 3.3 (decimal can only support precision up to 38), before any row was read. DorisLARGEINTasDECIMAL(39, 0)(#12787) and MySQLDECIMAL(65, x)both hit this.This PR implements the "Agreed design" in #12814:
ROW: carried through Spark asSTRINGplain decimal text, withseatunnel_decimal_precision/seatunnel_decimal_scalemetadata on the Spark field, and restored toDECIMAL(p, s)for transforms and sinks. Scale andNULLare kept. This applies both toInternalRowConverterand toSeaTunnelRowConverter(theGenericRowpath that transforms use).ARRAYorMAP(element, key or value, at any depth): rejected at job start withSPARK-TRANSLATION-01. The check runs per source table before the multi-table merge renames columns tocolumn0..N, so the error names the original table and full column path, the declared type, the Spark limit of 38 and the workarounds (leave the column out at the source, cast it to a string in the source query, or use Zeta/Flink). ASqltransformCASTcannot help on Spark because schema creation fails first, so the docs only list source-side workarounds.SPARK-TRANSLATION-02instead of being changed. Inconsistent carrier metadata on a Spark field fails withSPARK-TRANSLATION-03.InternalRowConverterno longer falls through fromDECIMALinto theARRAYbranch when it gets an unexpected value type.Not in scope: the MySQL
DECIMAL(p > 38)clamp toDECIMAL(38, 18)is a separate source-side issue (#12841).Does this PR introduce any user-facing change?
Yes, on the Spark engine only:
DECIMAL(p > 38)failed at startup on Spark.ROWfields work and keep their exact values.DECIMAL(p > 38)insideARRAY/MAPstill fails, but at job start with a clear message.Docs updated in en/zh:
engines/spark.md,api-design/spark-translation-layer.md,introduction/concepts/incompatible-changes.md.How was this patch tested?
WideDecimalTest, 20 cases): schema carrier and metadata round trip;InternalRowConverterandSeaTunnelRowConverter(throughRowEncoder) round trips; scale padding without rounding; rejection of rounding/overflow, malformed carrier text, inconsistent metadata; preflight forARRAY,MAPkey,MAPvalue,ARRAYinsideROW; narrow decimals in collections still allowed; multi-table jobs report the original table and column.FakeSourceToAssertIT, all engines incl. Spark 2.4 / 3.3):testWideDecimalToAssertSink:DECIMAL(39, 0)signed 128-bit max and min,0,NULL,DECIMAL(50, 10)with scale, a normalDECIMAL(10, 2)beside them, and the same values inside aROW, through aSqltransform; the sink checks the value class, scale and exact digits.testWideDecimalInMapToAssertSink: on Spark fails withSPARK-TRANSLATION-01naming`c_attrs.value`andDECIMAL(39, 0); on Zeta/Flink passes.all-connectors-it-*jobs pass, includingFakeSourceToAssertITon JDK 11 and 17. Unrelated failures on Zeta only:SplitClusterFaultToleranceIT.testStreamJobCancelResolvesWhenWorkerCrashesBeforeCancelAckandLocalFileIT.testLocalFileBinaryUpdateModeContinuousDiscoveryWithNonRecursiveScan;mysql-cdc-connector-it (17)hit the 2-hour job timeout.tmp/largeint-with-spark-wide-decimalmerges both PRs so the Doris Spark containers run against this change. [Fix][Connector-V2][Doris] Declare LARGEINT as DECIMAL(39, 0) #12787 keeps the Doris Spark tests enabled and adds a Spark-only Doris check for theARRAY/MAPerror (DorisIT.testNestedLargeintFailsOnSpark).Check list
incompatible-changes.mdupdated (en/zh).This contribution is made to Apache SeaTunnel.
🤖 Generated with Claude Code