Skip to content

[Fix][Translation][Spark] Carry DECIMAL with precision above 38 through Spark - #12862

Open
zhengxiang378928908-code wants to merge 4 commits into
apache:devfrom
zhengxiang378928908-code:fix/spark-wide-decimal
Open

zhengxiang378928908-code wants to merge 4 commits into
apache:devfrom
zhengxiang378928908-code:fix/spark-wide-decimal

Conversation

@zhengxiang378928908-code

@zhengxiang378928908-code zhengxiang378928908-code commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of this pull request

Closes #12814. Unblocks #12787.

Spark's DecimalType stops at precision 38, so any SeaTunnel DECIMAL(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. Doris LARGEINT as DECIMAL(39, 0) (#12787) and MySQL DECIMAL(65, x) both hit this.

This PR implements the "Agreed design" in #12814:

  • Top-level fields and fields inside a ROW: carried through Spark as STRING plain decimal text, with seatunnel_decimal_precision / seatunnel_decimal_scale metadata on the Spark field, and restored to DECIMAL(p, s) for transforms and sinks. Scale and NULL are kept. This applies both to InternalRowConverter and to SeaTunnelRowConverter (the GenericRow path that transforms use).
  • Inside ARRAY or MAP (element, key or value, at any depth): rejected at job start with SPARK-TRANSLATION-01. The check runs per source table before the multi-table merge renames columns to column0..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). A Sql transform CAST cannot help on Spark because schema creation fails first, so the docs only list source-side workarounds.
  • No silent changes to values: a value that would need rounding or overflow on write, and malformed text, a wrong scale or too many digits on read, fail with SPARK-TRANSLATION-02 instead of being changed. Inconsistent carrier metadata on a Spark field fails with SPARK-TRANSLATION-03.
  • InternalRowConverter no longer falls through from DECIMAL into the ARRAY branch when it gets an unexpected value type.

Not in scope: the MySQL DECIMAL(p > 38) clamp to DECIMAL(38, 18) is a separate source-side issue (#12841).

Does this PR introduce any user-facing change?

Yes, on the Spark engine only:

  • Before: any job whose schema has DECIMAL(p > 38) failed at startup on Spark.
  • After: top-level and ROW fields work and keep their exact values. DECIMAL(p > 38) inside ARRAY/MAP still 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?

  • Unit (WideDecimalTest, 20 cases): schema carrier and metadata round trip; InternalRowConverter and SeaTunnelRowConverter (through RowEncoder) round trips; scale padding without rounding; rejection of rounding/overflow, malformed carrier text, inconsistent metadata; preflight for ARRAY, MAP key, MAP value, ARRAY inside ROW; narrow decimals in collections still allowed; multi-table jobs report the original table and column.
  • E2E (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 normal DECIMAL(10, 2) beside them, and the same values inside a ROW, through a Sql transform; the sink checks the value class, scale and exact digits.
    • testWideDecimalInMapToAssertSink: on Spark fails with SPARK-TRANSLATION-01 naming `c_attrs.value` and DECIMAL(39, 0); on Zeta/Flink passes.
  • Fork CI: https://github.com/zhengxiang378928908-code/seatunnel/actions/runs/39095286760. Unit tests (JDK 11/17, Ubuntu/Windows) and all all-connectors-it-* jobs pass, including FakeSourceToAssertIT on JDK 11 and 17. Unrelated failures on Zeta only: SplitClusterFaultToleranceIT.testStreamJobCancelResolvesWhenWorkerCrashesBeforeCancelAck and LocalFileIT.testLocalFileBinaryUpdateModeContinuousDiscoveryWithNonRecursiveScan; mysql-cdc-connector-it (17) hit the 2-hour job timeout.
  • Together with [Fix][Connector-V2][Doris] Declare LARGEINT as DECIMAL(39, 0) #12787: branch tmp/largeint-with-spark-wide-decimal merges 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 the ARRAY/MAP error (DorisIT.testNestedLargeintFailsOnSpark).

Check list

  • No new Jar binary package.
  • Documentation updated (en/zh).
  • incompatible-changes.md updated (en/zh).
  • Not a connector change (translation layer only).

This contribution is made to Apache SeaTunnel.

🤖 Generated with Claude Code

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) (Doris LARGEINT as DECIMAL(39, 0), MySQL DECIMAL(65, x), PostgreSQL NUMERIC(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-text STRING with precision/scale metadata and restore DECIMAL(p, s) for transforms and sinks; reject wide decimals inside ARRAY/MAP at 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.java childPath(...) calls in convert(SeaTunnelRow, ...), reconvert(InternalRow, ...); SeaTunnelRowConverter.java convertRow/createFromGenericRow/reconvert; TypeConverterUtils.java case ROW/ARRAY/MAP in convert(SeaTunnelDataType).
  • Problem: the column path is built eagerly (parent + "." + name) for every nested ROW field of every row, although it is only needed when a wide decimal fails. checkNoWideDecimalInCollection/checkCollectionType also re-walk the type tree each time convert(dataType) is invoked, which happens per field per row in unpack.
  • Potential risk: extra garbage and CPU for every job with ROW columns, 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/the StructType builder rather than from the per-row convert(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

  1. Blockers — must be fixed

    • None in code. Merge only after the Build job on this head finishes green (the Spark E2E is the key evidence).
  2. Recommended — non-blocking

    • Issue 1 (hot-path overhead) and Issue 2 (checklist).

zhengxiang378928908-code added a commit to zhengxiang378928908-code/seatunnel that referenced this pull request Oct 19, 2026
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>
zhengxiang378928908-code added a commit to zhengxiang378928908-code/seatunnel that referenced this pull request Oct 19, 2026
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>
@zhengxiang378928908-code

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @DanielLeens. Both points are addressed in 36e16f4:

Issue 1 (hot path)

  • The row converters now pass only the field name down; no string is built per row. A nested ROW adds its name to the error (InvalidWideDecimalException.withParent) only when a value fails and the exception passes through it, so the message still shows the full path, e.g. outer.info.inner_big.
  • TypeConverterUtils.convert no longer walks the type tree for the ARRAY/MAP check on each call. The real check stays at schema build in MultiTableManager (per table, before the merge). As a safety net for other callers, convert only carries an "inside a collection" flag through its existing recursion, so there is no second walk.
  • New test valueErrorNamesFullPathOfDeeplyNestedColumn (ROW inside ROW, both converters), and collectionConversionOutsidePreflightStillFails now also covers MAP<STRING, ARRAY<ROW<DECIMAL(39, 0)>>>. seatunnel-translation-spark-common tests: 34 passed locally (JDK 11).

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 DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Doris LARGEINT as DECIMAL(39, 0), MySQL DECIMAL(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-text STRING with precision/scale metadata, restore DECIMAL(p, s) for transforms and sinks, and reject wide decimals inside ARRAY/MAP at 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 nested ROW field of every row, and convert(dataType) re-walked the type tree for the collection check on each call.
  • After: no string is built on the success path (InternalRowConverter.java convert/reconvert ROW branches, SeaTunnelRowConverter.java convert/reconvert), the exception rebuilds the dotted path on the way up through withParent, and TypeConverterUtils.convert only threads a collectionPart flag through its existing recursion (no second walk). The ROW branch passes collectionPart into its fields, so ARRAY<ROW<DECIMAL(39,0)>> and MAP<STRING, ARRAY<ROW<...>>> are still rejected; narrow decimals inside collections still pass.

Key findings:

  1. The hot-path concern is resolved. 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, which costs nothing unless an exception is thrown.
  2. The normal user path (Spark source schema -> MultiTableManager preflight -> source/transform/sink row conversion) reaches all changed logic, and p <= 38 plus every non-decimal type keep the pre-existing code.
  3. withParent correctly 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.
  4. The collection-error message produced by the safety net in TypeConverterUtils only names element/key/value (no table); the user-facing message with table and full column still comes from the MultiTableManager preflight, which is the documented entry point.
  5. The new test valueErrorNamesFullPathOfDeeplyNestedColumn asserts the full path outer.info.inner_big for both converters, and the extended collection test covers MAP<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.java InvalidWideDecimalException.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

  1. Blockers - must be fixed
    • None in code. Please wait for the Build job on this head to finish green; the Spark E2E is the key evidence.
  2. 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.

@DanielLeens

Copy link
Copy Markdown
Contributor

Update on the CI state for head 36e16f44f, since my last review was written while the run was still in progress.

The Build check on this head is now completed and green. In the fork run for the same SHA, the job connector-sensorsdata-it (17) that I flagged as failing earlier is green, and I see no failed job: License header, Dead links, Dependency licenses, unit-test (JDK 11/17 on ubuntu and windows), all-connectors-it-1..7, engine-v2-it, engine-k8s-it, transform-v2-it and the JDBC shards all report success. In the all-connectors-it-6 (11) job, FakeSourceToAssertIT finished with 34 tests run, 0 failures, 0 errors, which includes the two new wide-decimal configs. I did not break the result down per engine, so I cannot separately state the Spark 2.4 / 3.3 numbers.

My source-side conclusion is unchanged and I have no remaining code concerns: the previous Medium finding was addressed, the change stays inside seatunnel-translation-spark-common, tests and docs, and Issue 1 from my last review was informational only. The branch has no merge conflicts (it is behind dev, which is not blocking by itself).

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 DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
davidzollo previously approved these changes Oct 21, 2026

@davidzollo davidzollo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
davidzollo added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 21, 2026
@zhengxiang378928908-code

Copy link
Copy Markdown
Contributor Author

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

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for the queue details, @zhengxiang378928908-code. I checked the linked merge-group run: 39615004850 is now completed successfully. The current PR head remains 36e16f44fd26ab1d30e612f4ffbebd12b32f64f6, and GitHub reports reviewDecision=APPROVED; my technical conclusion remains clear as well.

There is no active auto-merge request in the current PR metadata, and the merge state is UNSTABLE. The run's success alone does not establish why the earlier queue entry was removed. A write-capable maintainer needs to inspect the queue's current required-check state and re-enqueue if its gates allow it. @davidzollo, your approval is already recorded; this remaining queue action needs maintainer permissions. Daniel has READ access, so I cannot re-enqueue or merge it on your behalf. No new code patch is requested here.

zhengxiang378928908-code added a commit to zhengxiang378928908-code/seatunnel that referenced this pull request Oct 24, 2026
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>
zhengxiang378928908-code added a commit to zhengxiang378928908-code/seatunnel that referenced this pull request Oct 24, 2026
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>
@github-actions github-actions Bot removed the approved label Oct 24, 2026
@zhengxiang378928908-code

Copy link
Copy Markdown
Contributor Author

@davidzollo Your approval was dismissed when I rebased onto dev on Oct 24 to resolve a conflict in incompatible-changes.md (EN/ZH). dev had added an entry at the same place, and I kept both. The PR's own changes are line-for-line identical to the version you approved. Could you re-approve it and add it back to the merge queue when you have a moment?

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) (Doris LARGEINT as DECIMAL(39, 0), MySQL DECIMAL(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-text STRING with seatunnel_decimal_precision / seatunnel_decimal_scale metadata, restore DECIMAL(p, s) for transforms and sinks, and reject wide decimals inside ARRAY/MAP at 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:

  1. The normal Spark user path (source schema build -> preflight -> source/transform/sink row conversion) reaches every changed branch, and isWideDecimal gates all of them, so p <= 38 and all non-decimal types keep the pre-existing code.
  2. No value is ever rounded or narrowed silently: RoundingMode.UNNECESSARY plus the precision check on write, and the exact-scale check on read.
  3. 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

  1. Blockers - must be fixed
    • None on the code side. The only remaining gate is CI: Build must finish green on this head.
  2. Recommended fixes - non-blocking
    • None. Please keep an eye on the incompatible-changes.md overlap with #12853 noted above.

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.

@zhengxiang378928908-code

Copy link
Copy Markdown
Contributor Author

@DanielLeens The fork Build for head 7b9d94255 is now green: https://github.com/zhengxiang378928908-code/seatunnel/actions/runs/40073956878 (85 jobs passed, 11 skipped, none failed).

The first attempt failed only in mysql-cdc-connector-it (17): MysqlCDCStopModeSpecificIT.testMysqlCdcInitialStartupWithLatestStop hit a ConditionTimeout. The same test passed on JDK 11 in that run, and this PR doesn't touch the MySQL-CDC connector. I re-ran only that failed job, and it passed. No code changed.

Could you re-approve when you have a moment? @davidzollo, once it is approved, could you add it back to the merge queue? Thanks!

@DanielLeens

Copy link
Copy Markdown
Contributor

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.

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for the clear CI write-up, @zhengxiang378928908-code. I confirmed that the fork Build run (https://github.com/zhengxiang378928908-code/seatunnel/actions/runs/40073956878) completed with success for head 7b9d94255 (attempt 2). The earlier mysql-cdc-connector-it (17) timeout is in a connector this PR does not touch, so re-running only that job was the right call (static reading only, nothing executed locally).

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 incompatible-changes.md conflict, the PR-owned diff matches what was approved earlier. The remaining step is on the committer side: GitHub still shows review required because the earlier committer approval was dismissed by the rebase. @davidzollo, could you please re-approve and re-enqueue when you have a moment? Thanks again for the careful work.

@SEZ9

SEZ9 commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

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:

  • The rebase onto dev only resolved the incompatible-changes.md (EN/ZH) conflict, keeping both the new dev entry and yours. A range-diff of head 7b9d94255 against the previously approved head 36e16f44f shows the PR-owned commits identical apart from the context of that docs hunk, and nothing under seatunnel-translation or connector-assert-e2e changed on dev between the two bases.
  • Your fork Build run 40073956878 for 7b9d94255 is green on attempt 2 (85 passed, 11 skipped). The only first-attempt failure was MysqlCDCStopModeSpecificIT.testMysqlCdcInitialStartupWithLatestStop in mysql-cdc-connector-it (17) with a ConditionTimeout; it passed on JDK 11 in the same run and this PR doesn't touch MySQL-CDC, so re-running just that job was the right call.

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:

  1. Please leave the branch at 7b9d94255 untouched (no force-push, no rebase) until it is through the queue, so the approval and the build result stay bound to the same head.
  2. If the required Build on the PR hits the same mysql-cdc-connector-it (17) flake, just note it here rather than pushing anything, so a committer can re-run the job.

Nice work on the wide-decimal handling and on documenting the ARRAY/MAP rejection behaviour clearly.

@zhengxiang378928908-code

Copy link
Copy Markdown
Contributor Author

@davidzollo Gentle ping: reviewers have no further asks on head 7b9d94255, and the fork Build is green. GitHub now reports a conflict with dev. Should I rebase (which will dismiss the approval again), or would you prefer to re-approve first and let me rebase right before enqueueing? Happy to go either way.

@SEZ9

SEZ9 commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

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 dev blocks merging regardless of approval state, so an approval granted on 7b9d94255 would have to be refreshed after the rebase anyway. Resolving it first means the next approval can land on a head that is actually mergeable, and the queue step does not have to wait on a second round-trip.

To keep the re-review as cheap as the last one, please do the same as you did for 36e16f44f -> 7b9d94255:

  1. Keep the PR-owned commits byte-identical where possible and post the git range-diff summary against 7b9d94255 so we can see that only the conflict resolution changed.
  2. Note which file(s) conflicted and how you resolved them; if it is the incompatible-changes.md (en/zh) ordering again, a one-line note is enough.
  3. Trigger the fork Build on the new head and link the run here, the same way you did with https://github.com/zhengxiang378928908-code/seatunnel/actions/runs/40073956878.

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.

@DanielLeens

DanielLeens commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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 7b9d942555fd52615ee25a2b626151b25fb0757e: Build is SUCCESS.

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 dev. Please sync the latest base and resolve the conflicts first; the resulting new head needs checks and re-review. This conflict gate is independent of CI and existing source findings.

@SEZ9

SEZ9 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the ping and for laying out both options, @zhengxiang378928908-code.

Since GitHub reports a conflict with dev, resolving it is the prerequisite for the final approval/queue step either way. The order of re-approval and queueing is the committer's call; my source clearance for head 7b9d94255 is separate from committer approval and queue permissions, so I can't re-approve or enqueue myself.

When you rebase:

  • Keep the resolution limited to the conflict and preserve both migration entries in incompatible-changes.md.
  • Post the new head SHA and a Build link for that head once it is green.
  • If convenient, a short note that the PR-owned diff is unchanged relative to 7b9d94255 apart from the conflict resolution will make the re-review quick.

I'll re-review the new head promptly once it is up. Thanks for your patience with the back-and-forth.

zhengxiang378928908-code added a commit to zhengxiang378928908-code/seatunnel that referenced this pull request Oct 29, 2026
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>
zhengxiang378928908-code added a commit to zhengxiang378928908-code/seatunnel that referenced this pull request Oct 29, 2026
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 DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Decimal

After:

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 BigDecimal

Key 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

  1. Blockers — must be fixed: No code-side blocker found. Required current-head CI and effective maintainer review/merge gates must be satisfied.
  2. 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.

@DanielLeens

Copy link
Copy Markdown
Contributor

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 1ce4e26cdbdcac4cf2d901c807463fe82cdf2822. Signal pull request update = SUCCESS; Build = FAILURE

Comparison: base dev, head 1ce4e26cdbdcac4cf2d901c807463fe82cdf2822, diverged, ahead 3 / behind 5; GitHub mergeable state blocked. Behind/diverged alone is recorded metadata and does not add a sync request.

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.

@DanielLeens

DanielLeens commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

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 1ce4e26cdbdcac4cf2d901c807463fe82cdf2822. Current checks: Build=FAILURE. Base dev, compare diverged, ahead 3 / behind 21; merge UNKNOWN / REVIEW_REQUIRED. Drift is recorded independently; it does not itself request synchronization. Daniel has READ permission. This is a CI/merge-gate clarification, not another full source review, effective approval or dismissal.

@SEZ9

SEZ9 commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Following up on the approval-versus-rebasing question.

The head is unchanged at 1ce4e26cdbdcac4cf2d901c807463fe82cdf2822. The latest comparison against dev is diverged, ahead 3 / behind 21, with merge state UNKNOWN / REVIEW_REQUIRED. As noted earlier, that drift is recorded metadata only; it does not by itself request a sync, and no conflicts have been reported. If conflicts do surface, resolve them before the final approval/queue step.

On CI: the blocking job remains unit-test (17, ubuntu-latest), run 40828465494 / job 123297627304, where PhysicalVertexTest setup reports a node failing to start with port-binding errors; the Build at 123363531370 is FAILURE, and the connector shard was cancelled. The merged d2fc2079035 changes HTTP-port allocation in other tests, not the PhysicalVertexTest fixture, so a simple sync is not a verified cure. I am not attributing a cause yet.

Concrete asks:

  1. After confirming no newer Build is active, rerun the failed unit-test job and the cancelled connector shard.
  2. If PhysicalVertexTest still fails, paste the new port/startup diagnostics here so we can attribute it precisely.
  3. Keep this PR limited to the Spark decimal change; no unrelated engine or test-fixture edits.

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.

@DanielLeens

Copy link
Copy Markdown
Contributor

Quick status update for head 1ce4e26cdbdcac4cf2d901c807463fe82cdf2822, which is unchanged since the last discussion.

The Build check on this head has now completed with SUCCESS (finished 2026-11-02T05:09Z): https://github.com/apache/seatunnel/runs/125043794701 . That clears the unit-test (17, ubuntu-latest) / PhysicalVertexTest startup failure that was blocking earlier, so the rerun suggested above did the job. I did not independently attribute the earlier port-binding failure; the green result on the same SHA is consistent with it having been environmental, and no code change was needed.

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 MERGEABLE with REVIEW_REQUIRED, so the only remaining step is a write-capable committer's approval and queue action (my approval does not satisfy the branch protection; I only have read access). @davidzollo, could you please take a look when you have a moment? @zhengxiang378928908-code, please keep the branch untouched until it goes through the queue so the approval and the Build result stay bound to the same head.

This is based on reading the code and GitHub's check state; I did not run anything locally.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@zhengxiang378928908-code

Copy link
Copy Markdown
Contributor Author

I rebased onto dev at a76348f1f9 to resolve a conflict in the English and Chinese incompatible-changes.md files. Both entries are intact, with dev's Iceberg sink entry on ordered publication and checkpoint replay immediately before the Spark entry.

Compared with 1ce4e26cd, the PR adds and removes exactly the same lines. git range-diff shows that only the surrounding context for the two changelog hunks changed. On the new head 87c65a8591, the Spark translation common module builds and WideDecimalTest passes (21 tests, JDK 11).

@DanielLeens, could you take another look when you have a chance? Thanks for reviewing the previous version.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 construction

After:

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 SEZ9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PostgreSQL NUMERIC(50, 10), or Doris LARGEINT once #12787 declares it as DECIMAL(39, 0)) failed at schema creation with decimal can only support precision up to 38, before any row was read.
  • Fix approach:
    • TypeConverterUtils maps a wide decimal to StringType (TypeConverterUtils.java:119-127) and stores seatunnel_decimal_precision / seatunnel_decimal_scale in the field metadata (:153-154).
    • InternalRowConverter and SeaTunnelRowConverter write the value with WideDecimalUtils.toCarrierText and read it with fromCarrierText. Both apply strict scale and precision checks and fail with SPARK-TRANSLATION-02 instead of rounding.
    • MultiTableManager rejects wide decimals inside ARRAY/MAP per source table before mergeSchema (MultiTableManager.java:63-67), so SPARK-TRANSLATION-01 names the real table and column path.
  • Coverage: WideDecimalTest covers the schema carrier, both converters and the preflight. FakeSourceToAssertIT adds 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: toCarrierText calls value.setScale(decimalType.getScale(), RoundingMode.UNNECESSARY) first and only afterwards checks scaled.precision() > decimalType.getPrecision(). Both rejection paths then call value.toPlainString(), and abbreviate trims the result to 64 characters only after the full string exists.
  • Large negative scale: for new BigDecimal("1E+100000000") into DECIMAL(39, 0), setScale(0, ...) has to materialise 10^100000000 as a BigInteger (roughly 40 MB). The precision check then fails, and toPlainString() builds a string of about 100 million characters.
  • Large positive scale: for 1E-100000000, setScale needs the same power of ten for the division and throws ArithmeticException. The catch block then calls toPlainString(), 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()) with p - s, and the fraction digits after stripTrailingZeros() with s. Call setScale only once both fit.

  • Build the message from a bounded rendering such as value.toString() (scientific notation) passed through abbreviate, not from toPlainString().

  • Add a unit test with 1E+100000000 and 1E-100000000 that 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: setScale runs before the precision check, and both rejection paths call value.toPlainString(). For a BigDecimal with an extreme exponent this expands the number before we reject it.

  • new BigDecimal("1E+100000000"): setScale(0, UNNECESSARY) builds 10^100000000 as a BigInteger, and toPlainString() then allocates a string of about 100 million characters that abbreviate trims only afterwards.

  • 1E-100000000: setScale throws, and the catch block calls toPlainString() 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. In toCarrierText, setScale(0, UNNECESSARY) materialises 10^100000000, then toPlainString() 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, MultiTableManager builds both converters on mergeCatalogTable.getSeaTunnelRowType() (MultiTableManager.java:81-83 and :94-96), whose fields mergeSchema renamed to column0..N.
  • So rowType.getFieldName(indexes[i]) in InternalRowConverter.parcel / unpack and SeaTunnelRowConverter.parcel / unpack yields column3, not the source column.
  • InvalidWideDecimalException carries 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 column argument and include the table in the message.
  • Add a multi-table case to WideDecimalTest that 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 MultiTableManager builds this converter on mergeCatalogTable.getSeaTunnelRowType(), so rowType.getFieldName(indexes[i]) is the merged placeholder (column0..N), not the source column. A rejected value then reports Column `column3` declared as DECIMAL(39, 0) with no table. That is the problem the preflight avoids for SPARK-TRANSLATION-01 by running before mergeSchema.

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)) and demo.b(id INT, total DECIMAL(50, 10)). A row of demo.a carries a 40-digit amount. InternalMultiRowCollector picks the demo.a converter, parcel calls convert(value, DECIMAL(39,0), "column1"), and the job fails with Column `column1` declared as DECIMAL(39, 0): value '...' is rejected because it has more than 39 digits. Neither amount nor demo.a appears.

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:190 still does decimalType = new DecimalType(20, 0) for DORIS_LARGEINT, and DorisTypeConverterV2.java:172 still builds new DecimalArrayType(new DecimalType(20, 0)) for ARRAY<largeint>.
  • Impact: a Doris user reading engines/spark.md (en and zh) will expect LARGEINT columns to take the new STRING-carrier path and ARRAY<LARGEINT> to fail with SPARK-TRANSLATION-01. With this PR alone neither happens. LARGEINT remains a normal Spark DECIMAL(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 LARGEINT as DECIMAL(39, 0)"). Calling DECIMAL(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/zh engines/spark.md, en/zh incompatible-changes.md).
  • Evidence: docs/en/introduction/concepts/incompatible-changes.md:166 If the Doris source declares LARGEINTasDECIMAL(39, 0), this applies to Doris ARRAYcolumns 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))或 PostgreSQL NUMERIC(50, 10)。
  • Suggested fix: On this head the Doris connector still declares LARGEINT as DECIMAL(20, 0) (AbstractDorisTypeConverter.java:190, and DorisTypeConverterV2.java:172 for ARRAY<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 LARGEINT column and an ARRAY<LARGEINT> column on Spark at this head. The SeaTunnel type is DECIMAL(20, 0), so the Spark schema is DecimalType(20,0), not the STRING carrier, and the array column does not fail with SPARK-TRANSLATION-01. That contradicts what engines/spark.md leads 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: InvalidWideDecimalException formats value '%s' into its message, and abbreviate truncates only above MAX_VALUE_LENGTH_IN_MESSAGE = 64.
  • A value that fits DECIMAL(39, 0) is at most 40 characters and one that fits NUMERIC(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 text is 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 reason text 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 %s declared 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 value 12345678901234567890123456789012345678901 (41 digits). toCarrierText fails at :170 and the task dies with Column `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 (the GenericRow path used by transforms) falls back to return field; when the type is wide and the value is neither String nor UTF8String. Whatever object is in the row reaches the transform or sink typed as DECIMAL(p, s) with no validation.
  • InternalRowConverter.reconvert is stricter. It accepts Decimal and BigDecimal as 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 the column parameter that the method already has and carries no SPARK-TRANSLATION code.

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. Use INVALID_WIDE_DECIMAL_VALUE with the column and the value class.
  • In InternalRowConverter.reconvert, add column to 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 String nor UTF8String, this return field; hands the raw object to the transform or sink as DECIMAL(p, s) without any check. InternalRowConverter.reconvert throws 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 whose big is 1.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 with Unexpected 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.fromMetadata is called only from the private TypeConverterUtils.convert(StructType), which is reached only through the public convert(DataType sparkType).
  • A search of all src/main code for TypeConverterUtils.convert( finds only SeaTunnel-to-Spark calls, all in InternalRowConverter. MultiTableManager.getTableSchema goes through parcel, 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 in src/main goes SeaTunnel-to-Spark, and the starter does not use it. So fromMetadata and SPARK-TRANSLATION-03 are exercised only by WideDecimalTest, 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() writes seatunnel_decimal_precision/seatunnel_decimal_scale via parcel, 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 reads Column `element` has type DECIMAL(39, 0) inside an ARRAY/MAP.
  • For ARRAY<ROW<amount DECIMAL(39, 0)>>, the ROW branch forwards the same collectionPart to its fields, so the nested field name amount is lost as well.
  • Impact: this is not reachable through the job path today. The only schema entry in src/main is parcel via MultiTableManager.getTableSchema, which runs after the preflight in the MultiTableManager constructor. Any other caller of TypeConverterUtils.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.amount form that WideDecimalUtils.check builds. 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 for ARRAY<ROW<...>> (the ROW branch forwards the same collectionPart).

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 with Column `element` has type DECIMAL(39, 0) inside an ARRAY/MAP. Neither items nor amount nor a table appears. The MultiTableManager preflight reports items.element.amount and 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:
    • isWideDecimal is public and called from TypeConverterUtils, InternalRowConverter and SeaTunnelRowConverter. It has no Javadoc.
    • metadata is public and has no Javadoc.
    • PRECISION_KEY and SCALE_KEY are public constants and are undocumented.
    • toCarrierText and fromCarrierText have a one-line description. They do not say what column may be (null inside an ARRAY or MAP, per the converters' own Javadoc) or that they throw InvalidWideDecimalException.
  • Impact: seatunnel_decimal_precision and seatunnel_decimal_scale are written into StructField metadata 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 isWideDecimal and metadata.
    • Add @param column and @throws on toCarrierText / 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 StructField metadata 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.java at lines 48-50, 60 and 65: there is no Javadoc on any of them. Renaming seatunnel_decimal_precision there 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: 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.
  • 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.
  • 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).
  • 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 IllegalArgumentException drops 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 TypeConverterUtils reports only element/key/value as the column, with no table, real column name or nested ROW field.
  • 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.

Thanks for the updates so far. Happy to discuss the remaining points.

@DanielLeens

Copy link
Copy Markdown
Contributor

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.

  1. Your expansion-order observation is correct: WideDecimalUtils.java:159-177 calls setScale before the precision check, and error paths call toPlainString before abbreviation. Extreme-exponent BigDecimal input can therefore do large work before rejection. This is conditional input evidence, not an observed PostgreSQL/Doris incident. Cheap digit/scale checks and bounded scientific rendering are the focused improvement; I have not executed the proposed huge-exponent experiment.
  2. MultiTableManager merges names to columnN, so runtime value errors do not preserve the original table/column identity. Collection preflight has the real path; that does not fix value-error attribution.
  3. The Doris documentation does run ahead of this head: AbstractDorisTypeConverter's LARGEINT branch remains DECIMAL(20,0), while docs/en/engines/spark.md:145 calls it DECIMAL(39,0). Please qualify the example on [Fix][Connector-V2][Doris] Declare LARGEINT as DECIMAL(39, 0) #12787 (or use a current PostgreSQL wide-NUMERIC example) in both languages and the migration note. My previous description overstated current Doris coverage.
  4. invalidValue includes the rejected text; a 64-character cap does not mask a 39-digit identifier/amount. Avoid exposing the whole value in the error; the field/type/reason is enough.
  5. SeaTunnelRowConverter.java:263-269 does return non-text objects without wide-decimal validation, while InternalRowConverter has a different fallback. This is an unexpected-carrier boundary, not proof that valid plain-text rows are rounded. Aligning validation and column/error context is appropriate.
  6. I agree that fromMetadata is a schema-conversion utility, not the normal row-restoration path. The architecture page should state that scope; its current wording can imply a runtime metadata check that is not invoked.
  7. The fallback collection error loses field path, but normal jobs hit MultiTableManager's real-table preflight first. Keep this utility diagnostic improvement distinct from a newly demonstrated production failure.
  8. The public metadata constants/method contracts deserve concise documentation, especially both keys' long values and the exception contract.

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 87c65a8591dba63d3a4ee17b0f8bb4786b717c37, not a new full source review. I inspected the named local source paths; no local build, test or SeaTunnel runtime was executed. Daniel has READ permission; effective maintainer approval and historical review dismissal remain separate repository actions.

zhengxiang378928908-code added a commit to zhengxiang378928908-code/seatunnel that referenced this pull request Nov 26, 2026
… 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>
@zhengxiang378928908-code

Copy link
Copy Markdown
Contributor Author

Thanks, @SEZ9, for the detailed review, and @DanielLeens for the follow-up. Pushed a0162f497d, which addresses all eight points:

  1. Bounded work before rejection. Before setScale, toCarrierText checks the integer digits, an upper bound on the length of the resulting text, and (when fraction digits must be dropped) the digit count and trailing zero bits. fromCarrierText rejects text longer than 3 + p + |s| before matching or parsing it, fromSparkValue checks a UTF8String's byte length before decoding it, and the digits of the unscaled value are counted before BigDecimal parses them. For a negative scale, the trailing zeros are checked in the text and only the digits before them are parsed, without a division. WideDecimalTest checks under a timeout that 1E+100000000, 1E-100000000 and oversized carrier text are rejected without being expanded.
  2. Multi-table attribution. MultiTableManager passes each source table's path and column names to its converters, so a value error names the source table and column instead of columnN.
  3. Doris example. Both Spark guides now use PostgreSQL NUMERIC(50, 10), and both incompatible-changes entries say this change alone does not affect Doris, because the Doris source still declares LARGEINT as DECIMAL(20, 0). The Doris migration wording is in [Fix][Connector-V2][Doris] Declare LARGEINT as DECIMAL(39, 0) #12787.
  4. No value in errors. A SPARK-TRANSLATION-02 error names the column path, the declared type, the reason, and the table when known. It omits the rejected value.
  5. Unexpected carriers. On Spark reads, both converters keep null and reject a non-text wide-decimal carrier with SPARK-TRANSLATION-02. The ordinary-decimal fallback error in InternalRowConverter now names the column.
  6. fromMetadata scope. The architecture page and the Javadoc say it is a schema read-back utility that the job path does not call. A null precision or scale now raises SPARK-TRANSLATION-03; a null scale could previously be read as 0.
  7. Fallback collection path. The TypeConverterUtils fallback builds the path only on failure, includes the root field when the caller passes it (for example tags.element.amount), and says the table is unknown at that point.
  8. Contracts. The two metadata keys (both values are stored as long), the public methods and the exception contract now have Javadoc.

Also in this push: wide decimals with a negative scale (PostgreSQL 15+ NUMERIC(p, -s)) now round-trip through the Spark carrier, and the read rule on the architecture page now states the limit precisely (the unscaled value at scale s has at most p digits).

Verification: with Spotless, the Spark translation common module builds and WideDecimalTest (31 tests), MultiTableManagerTest (7) and OffsetDateTimeUtilsTest (6) pass on JDK 11. The seatunnel-translation-spark-2.4 and -3.3 modules build.

About CI: I can't attach a fork run for this head. Actions on my fork has not run since 2026-11-05. Dispatching Build returns HTTP 422: Actions has been disabled for this repository, although the repository's Actions permissions API reports enabled: true. I'll post the Build link once it runs again. If a maintainer can start the checks from the upstream side, that would help too.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SEZ9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-F1 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.
  • PR12862-F2 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.
  • PR12862-F5 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.
  • PR12862-F6 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.
  • PR12862-F7 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.
  • PR12862-F3 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).
  • PR12862-F8 The fallback guard in TypeConverterUtils reports only element/key/value as the column, with no table, real column name or nested ROW field.
  • PR12862-F9 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.

Review conclusion

Conclusion: verification is incomplete; approval is not ready

Nice work — the previous concerns are addressed. Thanks again for the contribution.

@DanielLeens

Copy link
Copy Markdown
Contributor

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 a0162f497d5553d5b44936599d1bfb9cbf14c719, not a new full source review. Base dev compare: diverged, ahead 4 / behind 61. Branch drift alone is not a request to sync. No local build/test/runtime execution was performed. Daniel has READ permission; any required write-capable maintainer approval or historical-review dismissal remains separate.

@SEZ9

SEZ9 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the thorough follow-up on this PR. The eight points from the previous review are addressed on head a0162f497d5553d5b44936599d1bfb9cbf14c719:

  • WideDecimalUtils 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.
  • The docs describe fromMetadata as a schema read-back utility outside the job path.

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 transform-v2-it-part-2 / JDK 11 check (run 45758404126, job 139703189868). As reported in the thread, the Maven wrapper download returned HTTP 429 and the job stopped before test execution, so it gives no decimal-test result either way.

Remaining asks:

  1. Please rerun that failed lane once artifact access recovers, and share the new job URL if it fails again.
  2. Please keep unrelated wrapper or dependency changes out of this PR so it stays focused on the Spark decimal work.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Discussion][Translation][Spark] Explicit policy for DECIMAL precision > 38 on the Spark engine

4 participants