Repository navigation
[Fix][Connector-V2][File] Fail an ORC decimal that does not fit the target column - #12909
Conversation
|
The Fork run All four legs die at the same place, in This is a pre-existing break on
I checked this against the current I also reproduced it locally on a tree carrying no JDBC changes at all, and the identical four-leg failure appears on my unrelated #12899, which is a This PR is four files: No rerun here can go green until #12875 merges, so I am leaving the badge as it is rather than burning runner time. Once #12875 lands I will sync and rerun, and I am happy to do that sooner if a reviewer prefers. |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the careful write-up and for tracing this down to the two silent null sources, @SEPURI-SAI-KRISHNA. I reviewed the full diff at head b4c5a0ee45c7bf06ce0abf1da3756983be1cd08f (the ORC write strategy, the new test, EN/ZH incompatible-changes.md) and traced the write path from the sink into the ORC DecimalColumnVector.
What Problem Does This PR Solve?
- User pain point: the ORC file sink wrote
NULLinstead of the value whenever aDECIMALdid not fit the target column. The job finished successfully and the data was silently lost (Fixes #12908). - Fix approach: check both places that return
nullinstead of throwing (HiveDecimal.createabove precision 38, andenforcePrecisionScalewhen the value does not fit the declareddecimal(p,s)), and fail the write with the value and the target column in the message. - One-sentence summary: turn a silent decimal-to-NULL data loss in the ORC sink into an explicit, diagnosable failure.
1. Code Change Review
1.1 Core Logic Analysis
Before (OrcWriteStrategy.setDecimalColumnVector, dev):
decimalColumnVector.set(row, HiveDecimal.create((BigDecimal) value));After (OrcWriteStrategy.java:349-376 at the head):
HiveDecimal hiveDecimal = HiveDecimal.create(decimal);
HiveDecimal enforced = hiveDecimal == null ? null
: HiveDecimal.enforcePrecisionScale(hiveDecimal, decimalColumnVector.precision, decimalColumnVector.scale);
if (enforced == null) { throw new FileConnectorException(ILLEGAL_ARGUMENT, "Decimal value [...] does not fit ..."); }
decimalColumnVector.set(row, enforced);Runtime path (normal path is hit for every non-null decimal cell of an ORC sink):
FileSinkWriter.write(SeaTunnelRow)
-> OrcWriteStrategy.write(...) // batches rows into a VectorizedRowBatch
-> setColumn(value, vector, row) // OrcWriteStrategy.java:238-285, case DECIMAL (line 256-259)
-> setDecimalColumnVector(...) // changed method, line 349
-> HiveDecimal.create / enforcePrecisionScale
-> throw FileConnectorException // new: job fails at the offending row
-> DecimalColumnVector.set(row, enforced) // unchanged happy path
What I verified against the head source:
- The column vector precision and scale come from
TypeDescription.createDecimal().withScale(scale).withPrecision(precision)built from theDecimalType(OrcWriteStrategy.java:201-203), sodecimalColumnVector.precision/scaleare exactly the declared column precision and scale, which is the right thing to enforce against. setDecimalColumnVectorhas a single call site (setColumn, line 258), and nested list/map/struct decimals go through the samesetColumn, so the guard also covers nested decimals.FileConnectorException,CommonErrorCodeDeprecatedandHiveDecimalare all already imported (lines 27, 28, 35); there is no new dependency.- In-range values still end up in
decimalColumnVector.set(row, enforced);setre-applies the same enforcement internally, so the stored value is identical to before for values that fit.
1.2 Compatibility Impact
Partially incompatible, intentionally. Only jobs that previously lost data (an out-of-range decimal written as NULL) now fail at that row. Option names, schema, file layout and in-range output are unchanged. The behavior change is documented in EN and ZH incompatible-changes.md with a migration guide, which matches the project rule for behavior changes.
1.3 Performance / Side-Effect Analysis
The hot path adds one enforcePrecisionScale call per decimal cell. This is a small, allocation-light computation compared with the ORC encoding itself, and DecimalColumnVector.set already performs the same enforcement internally, so the added cost is at most one extra short-lived object per decimal value (I did not measure this; the estimate is based on reading the code). There is no new thread, buffer, retry or log in the hot path.
1.4 Error Handling and Logging
The failure is a hard exception with the value and decimal(p,s) in the message, which is the right level for "task-failing" data loss. I have two small, non-blocking observations.
Issue 1 (Low)
- Location:
OrcWriteStrategy.java:360-374 - Problem:
enforcePrecisionScalerounds extra fractional digits to the declared scale (for example1.239intodecimal(10,2)is stored as1.24) and only returnsnullwhen the integer part overflows. That silent rounding is the same as before this PR and is not touched, but the PR text says "a value the column cannot represent must fail", which a reader may take to include fractional rounding. - Potential risk: a user may assume that every lossy decimal conversion now fails, when only integer-part overflow does. This is based on my reading of Hive's
enforcePrecisionScalecontract; I did not run it. - Best improvement: one sentence in the
incompatible-changes.mdentry (or the code comment) stating that fractional digits beyond the declared scale are still rounded and only integer overflow fails. - Severity: Low. Raised by another reviewer: no.
Issue 2 (Low)
- Location:
OrcWriteStrategyTest.java(newwriteOneDecimalAndReadItBack, fixed pathsfile:///tmp/seatunnel/orc/decimal-<tag>) - Problem: the helper uses fixed
/tmppaths and asserts exactly one file is found. The existingtestCloseWriterWhenRollingFilein the same class avoids this withSystem.nanoTime()in the path. The two failing cases also do not callwriteStrategy.close()after the exception. - Potential risk: a re-run on a machine that still has output from a previous run, or leftover writer resources after the expected exception, can make the test order- or environment-dependent.
- Best improvement: add a unique suffix to the path and close the strategy in a
finally. - Severity: Low. Raised by another reviewer: no.
2. Code Quality Assessment
2.1 Coding Standards
Good. The comment on the fix explains why (two silent null sources, which one is reachable). No wildcard imports, no new dependency.
2.2 Test Coverage and Test Stability
OrcWriteStrategyTest.testOrcDecimalThatDoesNotFitTheColumnFailsInsteadOfBeingWrittenAsNull writes and reads back a real ORC file for three cases: in range (control), wider than the declared column, and beyond ORC maximum precision. It fails on the old code (the old code returns null instead of throwing), and the PR description reports that checking only HiveDecimal.create still fails the over-declared case, so the test pins the right half-fix. No existing assertion was weakened (additions only). Stability: Stable (no Thread.sleep, no timing), with the small path-hygiene note in Issue 2. It is @DisabledOnOs(WINDOWS) like the neighbouring ORC tests.
2.3 Documentation Updates
EN and ZH incompatible-changes.md are updated consistently. The ORC sink page itself has no decimal-specific text, so no further doc change is required.
3. Architectural Soundness
3.1 Elegance
Precise fix, at the single place where the ORC cell is populated.
3.2 Maintainability
Clear and local; the comment explains the two null sources.
3.3 Extensibility
Nothing new is introduced. If other writers ever need the same check, a tiny shared helper could be extracted then; not needed for this PR.
3.4 Historical-Version Compatibility
Files already written are unaffected. Only the write behavior for out-of-range decimals changes, and it is documented. I did not find any option, SPI or serialized-state change.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Fractional rounding beyond declared scale remains silent; wording could be clearer | OrcWriteStrategy.java:360-374 |
Low |
| 2 | Fixed /tmp paths and missing close() in the new test helper |
OrcWriteStrategyTest.java helper |
Low |
CI state (head b4c5a0ee4): the apache-side Build check points to the fork run, where the only failing jobs are the four unit-test legs. I opened one of them: the failure is JdbcOptionRuleCompletenessTest.testSinkRuleDeclaresAllSinkOptions in connector-jdbc ("unknown option keys: [numeric_special_value_as_null]"), which this PR does not touch. It is a dev-side break from the interplay of two merged PRs and is tracked in #12874 (fix in #12875, still open when I checked). The ORC change is not related to that failure. The PR is 8 commits behind dev.
5. Merge Recommendation
Conclusion: Ready to merge
Blockers:
- None in the code or tests of this PR.
Recommended fixes (non-blocking):
- Issue 1 (one clarifying sentence) and Issue 2 (unique test path plus
finally { close }). - Once #12875 lands, please sync the latest
devand rerun the failedunit-testjobs only; until then the redBuildis not attributable to this diff, so I am not treating it as a code blocker. A committer will still need the greenBuildbefore merging.
Overall assessment: a small, well-scoped data-integrity fix with a real round-trip test, a clear migration note and no compatibility surprises beyond the documented one.
Better alternative: none needed; the current location is the right one.
|
Thanks for the review, @DanielLeens. Both items are addressed and the branch is synced. Sync. You asked me to wait for #12875. It never landed: hutiefang76 closed it unmerged today, conflicting. The same repair reached Issue 1. You noted you had not run Your reading is exactly right: fractional digits beyond the declared scale are rounded HALF_UP and away from zero, silently, and only an integer part that does not fit, or a value beyond ORC's maximum precision of 38, produces null. Both documents now carry a bullet saying so. Issue 2. Done, but the halves differ in kind and I would rather say so than imply two bugs. The missing The fixed Validation, JDK 17: CI is in flight; I will report what it says rather than assume it. |
DanielLeens
left a comment
There was a problem hiding this comment.
Thank you @SEPURI-SAI-KRISHNA for the quick and thorough follow-up. Measuring enforcePrecisionScale against the resolved jars instead of relying on my reading, adding the "still rounded" bullet to both incompatible-changes.md files, moving the close() into a finally, and giving each invocation a unique directory all address the two items from my last round (both Low), and the explanation of what was and was not reproducible is appreciated. I re-read the whole PR diff from scratch at the current head 316e4f2ea9. This is a static review; nothing was built or run locally.
What Problem Does This PR Solve?
- User pain point: the ORC file sink wrote
NULLinstead of the value whenever aDECIMALdid not fit the target column. The job finished successfully and the data was silently lost (closes #12908). - Fix approach: check both places that return
nullinstead of throwing (HiveDecimal.createabove precision 38, andenforcePrecisionScalewhen the value does not fit the declareddecimal(p,s)), and fail the write with the value and target column in the message. - One-sentence summary: turns a silent decimal-to-NULL data loss in the ORC sink into an explicit, diagnosable failure, matching the Parquet sink.
1. Code Change Review
1.1 Core Logic Analysis
Before (OrcWriteStrategy.setDecimalColumnVector):
decimalColumnVector.set(row, HiveDecimal.create((BigDecimal) value));After (OrcWriteStrategy.java:349-376):
HiveDecimal hiveDecimal = HiveDecimal.create(decimal);
HiveDecimal enforced = hiveDecimal == null ? null
: HiveDecimal.enforcePrecisionScale(hiveDecimal, decimalColumnVector.precision, decimalColumnVector.scale);
if (enforced == null) { throw new FileConnectorException(ILLEGAL_ARGUMENT, "Decimal value [...] does not fit ..."); }
decimalColumnVector.set(row, enforced);Runtime path (the normal path reaches the changed code for every non-null decimal cell of an ORC sink):
FileSinkWriter.write(SeaTunnelRow)
-> OrcWriteStrategy.write(...) // fills a VectorizedRowBatch
-> setColumn(value, vector, row) // :238-262; null -> isNull[row]=true (unchanged), DECIMAL -> setDecimalColumnVector
-> HiveDecimal.create / enforcePrecisionScale
-> throw FileConnectorException // new: job fails at the offending row
-> DecimalColumnVector.set(row, enforced) // happy path, same stored value as before
Verified at the head: the column vector precision/scale come from TypeDescription.createDecimal().withScale(scale).withPrecision(precision) built from the DecimalType (OrcWriteStrategy.java:199-202), so the guard enforces exactly the declared column; true null cells are handled before this method, so they are not mistaken for overflow; the change sits in the single place where decimals are populated, so nested decimals are covered too; no new imports or dependencies.
1.2 Compatibility Impact
Partially incompatible, intentionally: only jobs that previously lost data (out-of-range decimal written as NULL) now fail at that row. Options, schema, file layout and in-range output are unchanged. The change is documented in EN and ZH incompatible-changes.md with migration guidance, and the new "Still rounded, not failed" bullet states the exact boundary (fractional digits beyond scale are rounded HALF_UP as before; only integer overflow or precision above 38 fails).
1.3 Performance / Side-Effect Analysis
One extra enforcePrecisionScale call per decimal cell, which DecimalColumnVector.set already does internally; at most one short-lived object per value. This is an estimate from reading the code, not a measurement. No new thread, buffer, retry or log on the hot path.
1.4 Error Handling and Logging
Hard failure with value and decimal(p,s) in the message, the right level for task-failing data loss. No blocking issues found; the two Low items from my previous round are resolved at this head.
2. Code Quality Assessment
2.1 Coding Standards
Good. The code comment explains why (two silent null sources, which one is reachable); no wildcard imports.
2.2 Test Coverage and Test Stability
OrcWriteStrategyTest.testOrcDecimalThatDoesNotFitTheColumnFailsInsteadOfBeingWrittenAsNull writes and reads back a real ORC file for three cases (in range control, wider than the declared column, beyond precision 38), asserting the exception message names the value and column. Reverting the guard makes the two failing cases stop throwing, so the test would go red on the original defect, and a create-only half-fix still fails the over-declared case. No existing assertion was weakened (additions only). Stability rating: Stable. The path now includes System.nanoTime() (OrcWriteStrategyTest.java helper, same pattern as testCloseWriterWhenRollingFile), close() runs in finally with a debug-logged failure so it cannot mask the asserted exception, there is no Thread.sleep and no shared static state, and the test is @DisabledOnOs(WINDOWS) like its neighbours.
2.3 Documentation Updates
EN and ZH incompatible-changes.md are consistent. The ORC sink page has no decimal-specific text, so no other doc change is needed.
3. Architectural Soundness
3.1 Elegance
Precise fix at the single place where the ORC cell is populated.
3.2 Maintainability
Clear and local.
3.3 Extensibility
Nothing new introduced; a shared helper is not needed now.
3.4 Historical-Version Compatibility
Already-written files are unaffected; only the write behavior for out-of-range decimals changes, and it is documented. No option, SPI or serialized-state change found.
4. Issue Summary
No blocking issues found, and no open issues from my previous round.
| Number | Issue | Location | Severity |
|---|---|---|---|
| - | None | - | - |
5. Merge Recommendation
Conclusion: Ready to merge
Blockers: none in the code, tests or docs.
Recommended non-blocking: none.
CI / mergeability: at the time of this review the Build check for head 316e4f2ea9 is still in progress, so please treat this as "code-ready, pending a green Build". The earlier red unit-test legs came from the connector-jdbc completeness-test break on dev, not from this diff; I confirmed that dev now carries the NOT_SINK_OPTIONS exclusion in JdbcOptionRuleCompletenessTest (it arrived with #12938, while #12875 was closed unmerged), and this head already includes that sync. The PR is 11 commits behind dev and the branch shows no merge conflict; behind_by is metadata only. A committer still needs the Build to finish green before merging.
Overall assessment: a small, well-scoped data-integrity fix with a real round-trip test, a clear migration note and no surprises beyond the documented behavior change.
Better alternative: none needed.
Thanks again, @SEPURI-SAI-KRISHNA, this is a nice contribution.
316e4f2 to
51c3cfa
Compare
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks again, @SEPURI-SAI-KRISHNA. I re-checked the PR at the new head 51c3cfabc9 (the branch was rebased and force-pushed since my last review at 316e4f2ea9). This is a static review; nothing was built or run locally.
What Problem Does This PR Solve?
- User pain point: the ORC file sink wrote
NULLinstead of the value whenever aDECIMALdid not fit the target column, so the job succeeded while data was silently lost (closes #12908). - Fix approach: check both places that return
nullinstead of throwing (HiveDecimal.createabove precision 38, andenforcePrecisionScalewhen the value does not fit the declareddecimal(p,s)) and fail the write with the value and target column in the message. - One-sentence summary: turns a silent decimal-to-NULL data loss in the ORC sink into an explicit, diagnosable failure.
1. Code Change Review
1.1 Core Logic Analysis
What changed since my last review: I diffed OrcWriteStrategy.java and OrcWriteStrategyTest.java between 316e4f2ea9 and 51c3cfabc9, and both files are byte-identical. The push is a rebase onto a newer dev (merge base is now 9ab97e15f3, the PR is 2 commits ahead and 5 behind dev). So my earlier code analysis still applies unchanged:
FileSinkWriter.write(SeaTunnelRow)
-> OrcWriteStrategy.write(...) // fills a VectorizedRowBatch
-> setColumn(value, vector, row) // true null cells handled before this point
-> setDecimalColumnVector // OrcWriteStrategy.java:349
-> HiveDecimal.create / enforcePrecisionScale
-> throw FileConnectorException // new: job fails at the offending row
-> DecimalColumnVector.set(row, enforced) // happy path, same stored value as before
The column vector precision/scale come from TypeDescription.createDecimal().withScale(scale).withPrecision(precision) (OrcWriteStrategy.java:199-202), so the guard enforces exactly the declared column. The normal path reaches the change for every non-null decimal cell.
1.2 Compatibility Impact
Partially incompatible, intentionally: only jobs that previously lost data (an out-of-range decimal written as NULL) now fail at that row. Options, schema, file layout and in-range output are unchanged. EN and ZH incompatible-changes.md document this, including the "Still rounded, not failed" boundary.
1.3 Performance / Side-Effect Analysis
One extra enforcePrecisionScale call per decimal cell (the column vector already does this internally). No new thread, buffer, retry or log on the hot path. This is an estimate from reading the code, not a measurement.
1.4 Error Handling and Logging
Hard failure with value and decimal(p,s) in the message, the right level for task-failing data loss. No code issues found. There is one merge-state issue, listed below.
Issue 1 (Medium): merge conflict with dev
- Location:
docs/en/introduction/concepts/incompatible-changes.mdanddocs/zh/introduction/concepts/incompatible-changes.md(new entry under## dev) - Problem: GitHub reports the PR as
CONFLICTING/DIRTY. The Java files are untouched bydevsince the merge base; the only files changed on both sides are the twoincompatible-changes.mdfiles, since other merged PRs also add entries at the top of the## devsection (my inference from comparing the merge base todev; I did not run the merge). - Risk: the PR cannot be merged until it is resolved.
- Best fix: please sync with the latest
devand resolve the conflict by keeping both entries (the ORC entry and the entries that landed ondev), in both EN and ZH. - Severity: Medium. Raised by another reviewer: no.
2. Code Quality Assessment
2.1 Coding Standards
Good. The comment explains why (two silent null sources); no wildcard imports; no new dependency.
2.2 Test Coverage and Test Stability
OrcWriteStrategyTest.testOrcDecimalThatDoesNotFitTheColumnFailsInsteadOfBeingWrittenAsNull does a real write/read round trip for three cases (in-range control, wider than the declared column, beyond precision 38) and asserts the message names the value and the column. It would go red if the guard were reverted. Additions only, so nothing was weakened. Rating: Stable (unique System.nanoTime() path, close() in finally, no sleeps, no shared static state, @DisabledOnOs(WINDOWS) like its neighbours).
2.3 Documentation Updates
EN and ZH incompatible-changes.md are consistent and complete. They only need the conflict resolved (Issue 1).
3. Architectural Soundness
3.1 Elegance
Precise fix at the single place where the ORC cell is populated.
3.2 Maintainability
Clear and local.
3.3 Extensibility
Nothing new introduced; no shared helper needed now.
3.4 Historical-Version Compatibility
Already-written files are unaffected. Only the write behavior for out-of-range decimals changes, and it is documented. No option, SPI or serialized-state change.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Merge conflict with dev in the two incompatible-changes.md files |
docs/{en,zh}/introduction/concepts/incompatible-changes.md |
Medium |
5. Merge Recommendation
Conclusion: Ready to merge after fixes
Blockers (must fix):
- Issue 1: please sync with the latest
devand resolve the docs conflict (keep both entries, EN and ZH). No code or test change is needed.
Recommended fixes (non-blocking): none.
CI: the fork run 40106763362 for head 51c3cfabc9 completed with success. The apache-side Build check was still pending at the time of this review, and it should follow the fork run. A committer still needs it green before merging, and the rebase on conflict resolution will trigger a fresh run.
Overall assessment: the code, tests and docs content are unchanged from the version I already considered ready; the only remaining item is the mechanical conflict resolution after the rebase.
Better alternative: none needed.
|
Thanks for your patience. The CI fact in my previous review has changed: the required Build is now SUCCESS for unchanged head The remaining merge gate is the actual merge conflict: GitHub currently reports DIRTY against Compare metadata is |
…e its writer The helper wrote to a fixed /tmp directory per tag, so its single file assertion depended on what an earlier or unrelated run had left behind. It now writes to a fresh directory per invocation, the same way testCloseWriterWhenRollingFile already does. close() sat after write(), so the two failing cases never reached it and left the write strategy open. It now runs in a finally block, and a failure to close is logged rather than replacing the FileConnectorException under assertion. The incompatible-changes entry for this change gains a bullet stating that rounding beyond the declared scale is unchanged: 1.239 written into a decimal(10,2) column is still stored as 1.24, and only an integer part that does not fit the declared precision, or a value above ORC's maximum precision of 38, now fails.
51c3cfa to
a1aaa60
Compare
There was a problem hiding this comment.
Thanks for the update. I re-read the complete current diff and traced the relevant production callers and regression tests. This assessment belongs to the current head, separately from earlier-head CI.
What problem this PR solves
- User pain: An out-of-range decimal could silently become NULL in an ORC column instead of failing the write.
- Fix approach: Check both HiveDecimal construction and enforcement against the actual target vector precision/scale before assigning the cell.
- One-line summary: Fail a decimal overflow with context rather than losing its value silently.
Example: 12345678901234 into decimal(10,2) now fails; 123.45 still round-trips, and fractional rounding such as 1.239 to 1.24 remains the existing behavior.
1. Code-change review
1.1 Core logic analysis
All four files: ORC decimal conversion, existing writer test extension and EN/ZH upgrade notes. The complete target-relative diff was read at a1aaa6005668d05f8f1277e54d4ca38d27f459a4, not just the latest commit. Focused correctness fix.
Before / after:
Before: vector.set(row, HiveDecimal.create(value)) could silently set NULL
After: hiveDecimal=create(value); enforced=enforcePrecisionScale(hiveDecimal,p,s)
enforced==null -> FileConnectorException(value, decimal(p,s))
otherwise vector.set(row,enforced)
Complete relevant execution chain:
File sink writer -> OrcWriteStrategy.write():74
-> existing row/vector conversion -> setColumn():256-258 DECIMAL
-> setDecimalColumnVector():349-382
-> HiveDecimal.create -> enforcePrecisionScale using actual vector fields
-> failure propagates through the existing file-writer task failure path
-> valid enforced value enters the existing ORC batch/file/checkpoint commit lifecycle
Key findings:
- Ordinary decimal writes reach the guard, including a value wider than an otherwise legal declared column. The fix is not limited to an impossible declared precision above 38.
- Both global HiveDecimal limits and narrower target precision/scale are checked.
- Existing fractional rounding is preserved and now documented; the PR does not promise lossless scale enforcement.
- The failing writer test now closes the strategy in finally. A close error cannot replace the conversion exception under assertion.
- No blocking finding remains; the new head requires its own Build result.
Community context: The author correctly distinguishes the real missing-close leak from a fixed-path risk that was not reproduced. I accept that distinction rather than claiming an observed flaky failure. Their #12875 correction is also right: that PR closed unmerged and #12938 supplied the relevant shared repair. No independent active maintainer review was present.
1.2 Compatibility impact
Partially incompatible error behavior: jobs that previously lost an overflowing decimal as NULL now fail. Valid values, configuration/API, ORC layout and state formats are unchanged. EN/ZH upgrade notes explain wider target precision/scale or explicit upstream rounding, and distinguish value overflow from already-invalid declarations.
1.3 Performance / side effects
The production cost and ownership implications are described below. The affected hot path performs an additional precision/scale enforcement before the vector setter performs its own check. This is bounded decimal arithmetic per value, without new retained buffers, threads, locks or network calls. File/transaction ownership is unchanged; failing a row avoids silent value loss.
1.4 Error handling and logging
The existing exception and logging boundaries remain in place. No new credential logging, swallowed production exceptions or false success path was found.
No blocking findings. Previous numbered findings are closed as described above; no new formal issue is raised.
2. Code-quality assessment
2.1 Code conventions
The changed production behavior is explained by comments or Javadoc; explicit imports and ASF headers are retained. The scoped whitespace check produced no entries.
2.2 Test coverage and stability
Stability rating: Stable. No local build, unit/integration test, container or service was run. OrcWriteStrategyTest:250-359 performs real deterministic file write/read for a valid control and asserts both target-column and ORC-wide overflow. Unique per-invocation paths avoid stale-output dependence; writer close is in finally. Temporary test output remains and optional TempDir/reader-finally cleanup would improve hygiene, but no order/timing-based assertion is introduced. No server/container E2E execution is claimed.
Exact current-head fork evidence at a1aaa6005668d05f8f1277e54d4ca38d27f459a4: Build 40201613826: queued/no conclusion. Apache required-check and review gates remain independent of the fork run. Queued/in-progress/cancelled is not success; the earlier-head result does not transfer to this head.
2.3 Documentation
Both upgrade notes now explicitly preserve HALF_UP scale rounding and explain the fail-versus-NULL change. The obsolete conflict and older JDBC failure statements are superseded by this current-head assessment.
3. Architectural soundness
3.1 Solution quality
A focused fix at the existing ownership/conversion boundary.
3.2 Maintainability
The regression coverage pins the concrete failing behavior rather than merely asserting that an option or helper exists.
3.3 Extensibility
Keep shared options linked to their actual definitions and connector-specific limits explicit. No new extension API is introduced.
3.4 Historical compatibility
The stated behavior correction preserves existing schemas and serialized state. No automatic state migration is introduced.
4. Findings summary
No blocking findings.
5. Merge conclusion
Conclusion: Can merge
- Blocking items: No source blocker from Daniel. Complete current-head required CI and obtain effective write-capable maintainer approval.
- Non-blocking recommendations: Optional test hygiene: use managed temporary storage and put the reader close in finally/try-with-resources where supported; keep the fix focused on decimal correctness.
I support merging once the remaining repository CI and reviewer gates pass.
Compare against dev: diverged, ahead 2 / behind 1, merge conflict=False. Drift is recorded independently; it does not itself justify a sync-first comment without an unrelated CI failure.
Daniel has READ permission. This COMMENT is a technical assessment, not an effective write-level approval. A write-capable maintainer must confirm repository gates and supply the effective approval.
Local evidence: exact-head fetch/checkout on seatunnel-review-12909, complete diff and source call-chain reads cited above. No runtime verification was claimed.
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks again for the contribution, @SEPURI-SAI-KRISHNA. The CI fact in my previous review has changed: the Build check (run) is now SUCCESS on the unchanged head a1aaa6005668.
In my last review CI was the only remaining gate and I had no outstanding source-level blocker, so I am changing my earlier comment-only review to an approval. The final merge still needs a write-capable committer. Thanks for the careful work!
…flow # Conflicts: # docs/en/introduction/concepts/incompatible-changes.md # docs/zh/introduction/concepts/incompatible-changes.md
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for keeping this branch current, @SEPURI-SAI-KRISHNA. Since my last review (approval on a1aaa60056) the only new commit is a merge of dev into the branch, so I re-read the full PR diff at head 398ce30924 rather than assuming nothing moved. This is a static source review; CI is the runtime evidence.
What Problem Does This PR Solve?
User pain point: The ORC sink wrote NULL instead of the value whenever a DECIMAL did not fit the target column, with no exception or log line, so a job succeeded while silently dropping data.
Fix approach: OrcWriteStrategy#setDecimalColumnVector now guards both silent-null sources (HiveDecimal.create above precision 38, and enforcePrecisionScale against the declared column precision/scale) and throws a FileConnectorException naming the value and the column.
One-sentence summary: An out-of-range decimal now fails the ORC write loudly, matching the Parquet sink, instead of being persisted as NULL.
1. Code Change Review
1.1 Core Logic Analysis
Before:
decimalColumnVector.set(row, HiveDecimal.create((BigDecimal) value));After:
HiveDecimal hiveDecimal = HiveDecimal.create(decimal);
HiveDecimal enforced = hiveDecimal == null ? null
: HiveDecimal.enforcePrecisionScale(hiveDecimal, decimalColumnVector.precision, decimalColumnVector.scale);
if (enforced == null) { throw new FileConnectorException(ILLEGAL_ARGUMENT, "... does not fit the target ORC column decimal(p,s) ..."); }
decimalColumnVector.set(row, enforced);Key findings:
- The merge commit changed nothing in the four files of this PR (two docs,
OrcWriteStrategy,OrcWriteStrategyTest); the effective diff is the same as the one I approved. - Fractional digits beyond the declared scale are still rounded by
enforcePrecisionScale; only an integer part that does not fit the precision, or a value beyond precision 38, fails. This is documented in the PR and in the incompatible-changes entry. - Passing the already-enforced value to
set()keeps in-range output byte-identical to before.
Runtime path:
Source row -> MultiTableSinkWriter / FileSinkWriter.write
-> OrcWriteStrategy.write -> setColumn -> setDecimalColumnVector
-> HiveDecimal.create + enforcePrecisionScale
-> fits: DecimalColumnVector.set (unchanged output)
-> does not fit: FileConnectorException -> task fails, no commit of that file
The normal write path reaches the changed branch for every DECIMAL cell, so this is a main-path fix, not a recovery-only one.
1.2 Compatibility Impact
Partially incompatible. Data that previously became NULL now fails the job. No option, schema, file layout, or API changed, and in-range values are written exactly as before. The behavior change is declared in docs/en/introduction/concepts/incompatible-changes.md and the zh counterpart with a migration guide, as the repository requires.
1.3 Performance / Side-Effect Analysis
One extra enforcePrecisionScale call per decimal cell (it was already performed internally by set(), so effectively a duplicate cheap arithmetic check); no new allocation of note, no buffering, no extra threads or connections. Fine for very high-volume jobs.
1.4 Error Handling and Logging
The exception carries the value and the target decimal(p,s) plus an actionable hint, and nothing sensitive beyond the cell value being written. No issues found.
2. Code Quality Assessment
2.1 Coding Standards
Imports, formatting and comments follow the project style; the comment on the guard explains the why. No new public method, so no missing-javadoc concern.
2.2 Test Coverage and Test Stability
OrcWriteStrategyTest adds a control case (in range, round trips as 123.45), the reachable over-declared case (12345678901234 into decimal(10,2)), and the beyond-38 case. Each failing case asserts the exception type and that the message names the value and column, so removing either guard makes the matching case fail.
Flaky-test stability analysis: each invocation uses a fresh /tmp/seatunnel/orc/decimal-<tag>-<nanoTime> directory (OrcWriteStrategyTest helper writeOneDecimalAndReadItBack), so leftover state cannot affect the single-file assertion; there are no sleeps, threads, or timing assumptions; the close failure after a failed write is swallowed deliberately and does not mask the asserted exception; the test is @DisabledOnOs(WINDOWS), consistent with the neighbouring tests. Rating: Stable.
2.3 Documentation Updates
Both docs/en and docs/zh incompatible-changes entries were added and match the code behavior (including the rounding caveat). No connector option docs are affected.
3. Architectural Soundness
3.1 Precise fix / Temporary workaround / Long-term solution
A precise root-cause fix at the single place the unchecked conversion lives, not a workaround.
3.2 Scope
Limited to OrcWriteStrategy; no shared or engine classes touched.
3.3 Consistency
Aligns the ORC sink with the Parquet sink in the same module on overflow handling.
3.4 Risk
Low. The only behavior change is intentional and documented.
4. Issue Summary
| # | Severity | Location | Summary |
|---|---|---|---|
| - | - | - | No source-level issues found |
5. Merge Recommendation
Conclusion: Ready to merge
Blockers:
- CI only: the required
Buildcheck on head398ce30924is still in progress (fork run queued at the time of review: https://github.com/apache/seatunnel/runs/122687553027). I could not see a result yet, so please let it finish; I have no source-level blocker.
Recommended fixes: none.
Overall assessment: the head differs from my previously approved commit only by a dev merge, the PR's own diff is unchanged, and the change is a small, correct, well-tested and well-documented fix. The branch is 0 commits behind dev. A write-capable committer still needs to perform the merge once CI is green. Thanks again for the careful work!
|
Thanks for the contribution. The CI fact cited in my previous conclusion has changed; this follow-up updates that gate on the unchanged reviewed head, without issuing another full source review. Gate snapshot (2026-10-28T15:43:46+00:00), head CI was previously the only remaining technical gate in my conclusion; CI is now passing, so that CI objection is withdrawn and my technical conclusion is clear to proceed. Daniel currently has READ permission. I have not changed the effective GitHub review state to APPROVED; a write-capable maintainer must perform the final approve/dismiss action required by branch protection. Comparison recorded in this scan: base |
|
GitHub now reports an actual content conflict (CONFLICTING / DIRTY), superseding the earlier no-conflict snapshot on this unchanged head. Please reconcile the latest base while preserving both this PR's change and the intervening upstream work, then obtain required checks on the resulting commit. This request is based on the conflict, not the number of commits behind. Existing-head CI cannot validate that future resolution. My prior source conclusion remains clear for the reviewed scope; optional recommendations remain optional. The new conflict and current CI/repository approval gates are separate from that technical conclusion. Checked 2026-10-31T03:03:53.154826+00:00; unchanged head This is a discussion/CI clarification, not another full source review or an effective maintainer approval. Daniel has READ repository permission; a write-capable maintainer owns required approval/dismissal. |
…flow # Conflicts: # docs/en/introduction/concepts/incompatible-changes.md # docs/zh/introduction/concepts/incompatible-changes.md
|
@DanielLeens resolved by merging |
DanielLeens
left a comment
There was a problem hiding this comment.
Thank you @SEPURI-SAI-KRISHNA for resolving the merge conflict so promptly. My last review (approval on a1aaa60056, re-confirmed at 398ce30924) had no source-level blockers, and there is nothing new to carry over. Since then the only new commit is a second merge of dev (head 508400adc3). I re-read the whole PR diff from scratch rather than assuming nothing moved. This is a static review; CI is the runtime evidence.
What Problem Does This PR Solve?
- User pain point: the ORC sink wrote
NULLinstead of the value whenever aDECIMALdid not fit the target column, with no exception or log line, so a job succeeded while silently dropping data (closes #12908). - Fix approach:
OrcWriteStrategy#setDecimalColumnVectornow guards both silent-null sources (HiveDecimal.createabove precision 38, andenforcePrecisionScaleagainst the declared column precision/scale) and throws aFileConnectorExceptionnaming the value and the column. - One-sentence summary: an out-of-range decimal now fails the ORC write loudly, matching the Parquet sink, instead of being persisted as
NULL.
1. Code Change Review
1.1 Core Logic Analysis
Before:
decimalColumnVector.set(row, HiveDecimal.create((BigDecimal) value));After (OrcWriteStrategy.java, setDecimalColumnVector, around lines 349-376):
HiveDecimal hiveDecimal = HiveDecimal.create(decimal);
HiveDecimal enforced = hiveDecimal == null ? null
: HiveDecimal.enforcePrecisionScale(hiveDecimal, decimalColumnVector.precision, decimalColumnVector.scale);
if (enforced == null) { throw new FileConnectorException(ILLEGAL_ARGUMENT, "Decimal value [...] does not fit ..."); }
decimalColumnVector.set(row, enforced);Runtime path (every non-null DECIMAL cell reaches the changed code, so this is a main-path fix):
FileSinkWriter.write(SeaTunnelRow)
-> OrcWriteStrategy.write -> setColumn
-> setDecimalColumnVector
-> HiveDecimal.create + enforcePrecisionScale
-> fits: DecimalColumnVector.set (same stored value as before)
-> does not fit: FileConnectorException -> task fails, file not committed
Key findings:
- The merge changed nothing in this PR's own effective diff: it still touches exactly four files (EN/ZH
incompatible-changes.md,OrcWriteStrategy,OrcWriteStrategyTest), and no otherdevcommit since my last review touchedconnector-file-base. - Column precision/scale come from the declared
DecimalType, so the guard enforces exactly the declared column; truenullcells are handled before this method. - Fractional digits beyond scale are still rounded (HALF_UP) as before; only integer overflow or precision above 38 fails. This is stated in the docs entry.
1.2 Compatibility Impact
Partially incompatible, intentionally and documented. Data that previously became NULL now fails the job. No option, schema, file layout or API changes; in-range output is unchanged. The EN and ZH incompatible-changes.md entries carry migration guidance.
1.3 Performance / Side-Effect Analysis
One extra enforcePrecisionScale call per decimal cell (set() already does the same internally), at most one short-lived object per value; no new buffering, threads, retries or logging on the hot path. Safe at very high volume (estimate from reading the code, not a measurement).
1.4 Error Handling and Logging
The exception names the value and the target decimal(p,s) and gives an actionable hint. No issues found.
2. Code Quality Assessment
2.1 Coding Standards
Imports, formatting and the explanatory comment follow project style. No new public API.
2.2 Test Coverage and Test Stability
OrcWriteStrategyTest adds an in-range control, the reachable wider-than-declared case, and the beyond-38 case, each asserting the exception type and that the message names the value and column; removing either guard turns a case red. Stability: each invocation uses a unique /tmp/seatunnel/orc/decimal-<tag>-<nanoTime> directory, there are no sleeps, threads or timing assumptions, close failures after a failed write are deliberately swallowed, and the test is @DisabledOnOs(WINDOWS) like its neighbours. Rating: Stable.
2.3 Documentation Updates
EN and ZH entries are present and match the code, including the rounding caveat.
3. Architectural Soundness
A precise root-cause fix at the single place the unchecked conversion lives, not a workaround. Scope is limited to OrcWriteStrategy, no shared or engine classes are touched, and it aligns ORC with the Parquet sink. Risk is Low.
4. Issue Summary
| # | Severity | Location | Summary |
|---|---|---|---|
| - | - | - | No source-level issues found |
5. Merge Recommendation
Conclusion: Ready to merge
Blockers:
- CI only: the required
Buildcheck on head508400adc3was still in progress when I checked (the apache-side check is a pointer to the fork run), and GitHub reports the PR as BLOCKED rather than conflicting, so the earlier conflict is resolved. Please letBuildfinish; I have no source-level blocker. EarlierBuildruns on this unchanged diff were green.
Recommended fixes: none.
Overall assessment: a small, correct, well-tested and well-documented data-integrity fix. A write-capable committer still needs to perform the merge once CI is green. Thanks again for the careful work!
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks again for the careful contribution. The CI fact in my preceding full review has changed: the previously pending Apache Build has completed SUCCESS on unchanged head 508400adc3f3af9c50ad3ec5680c8bb22256f64b. The previous review left CI as the sole technical blocker. It is now passing, so I am submitting an approval.
I checked the successful exact-head fork Build and all 70 job conclusions. All four JDK 11/17 unit-test legs and connector-file-local-it on JDK 11 and 17 succeeded. Skipped jobs are not counted as executed coverage. No local build or test was run.
Merge recommendation
- Source blockers: none remain in my preceding full review.
- CI blocker: the previously pending check is now cleared. No extra contributor commit, sync or rerun is requested for this completed check.
- Non-blocking recommendations from that review remain optional.
- Effective repository approval/merge gate: GitHub currently reports
UNKNOWN/REVIEW_REQUIRED. Daniel has READ repository permission. This technical review does not claim to satisfy write-reviewer protection, dismiss another review or merge the PR; a write-capable maintainer must reconcile any remaining effective gate.
Overall: the source conclusion is unchanged and the previously missing CI evidence is now present. This is a CI-state follow-up, not a second full source review. Checked 2026-11-01T11:12:04.885373+00:00.
davidzollo
left a comment
There was a problem hiding this comment.
+1
LGTM, appreciate your solid contribution, keep up the excellent work
Thanks for your contribution! This is a solid addition to the project, and your attention to detail really shows. Contributors like you are what keep this community moving forward. Feel free to keep the PRs coming — we're always glad to have you here!
Please ignore the following message if you have joined in the Slack~
To facilitate focused communication among contributors, we’ve created a brand-new dedicated #contributors channel in official Slack workspace.
Slack workspace link: https://s.apache.org/seatunnel-slack
This channel is designed for technical discussions, feature design brainstorming, roadmap sync and direct communication with project core Contributors. Everyone who contributes code, docs, test cases or community ideas is warmly invited to join, share thoughts and collaborate together under The Apache Way. Welcome to join 😄
Yes, and thank you for maintaining it: this is a contribution to Apache SeaTunnel.
Scope agreed before submission
Per this repository's contribution workflow, the three questions were put to the developer and answered before any code was written:
NULL, which keeps losing data; and adding a config option to choose, which this repository asks not to do without necessity. Scope note, since "cannot represent" could be read more widely than intended: fractional digits beyond the declared scale are still rounded, so1.239intodecimal(10,2)is still stored as1.24. Only an integer part that does not fit the declared precision, or a value beyond ORC's maximum precision of 38, fails.connector-file-base, onlyOrcWriteStrategy. No option, schema, file layout or API change. In-range values are written exactly as before.spotless:apply, the mandatory-DskipTests verify, the full module unit run, and a mutation matrix. No E2E case, for the reason given below.Purpose of this pull request
The ORC sink wrote
NULLinstead of the value whenever aDECIMALdid not fit the target column, with no exception, warning or log line, so a job completed successfully while dropping data.decimalColumnVector.set(row, HiveDecimal.create(value))has two silent null sources.HiveDecimal.createreturnsnullabove ORC's maximum precision of 38, andDecimalColumnVector.setinternally callsenforcePrecisionScale, which returnsnullwhen the value does not fit the precision and scale the column actually declares. Neither was checked.Measured on
dev, writing one row and reading it back:123.45decimal(10,2)123.45123.45decimal(38,0)null12345678901234decimal(10,2)nullThe third case is the reachable one: a value merely wider than its declared column, from a narrow or inferred JDBC precision, a sampled schema, a schema-less source, or a SQL transform that multiplies decimals.
Given the same two inputs the Parquet sink in this module already throws
AvroTypeException: Cannot encode decimal with precision 39 as max precision 38and... precision 16 as max precision 10, so the two sinks disagreed about whether silent loss is acceptable. This change makes them agree.The change
Apply both guards and fail with the value and the target column:
Checking
HiveDecimal.createalone is not enough, and the mutation matrix below pins that: it only catches the precision-above-38 case, while the reachable case is nulled insideset()byenforcePrecisionScale.Does this PR introduce any user-facing change?
Yes. A job that silently dropped values now fails at the offending row. Documented in
docs/enanddocs/zhincompatible-changes.md, with migration guidance: widen the declared precision or scale, or round the value before the sink.How was this patch tested?
A new test in the existing
OrcWriteStrategyTest, which had no decimal coverage at all. It writes a decimal into a declareddecimal(p,s)column and reads it back, covering the in-range control, a value wider than the declared column, and a value beyond ORC's maximum precision of 38, asserting that each failure names the value and the target column.Mutation matrix:
HiveDecimal.createonly (the plausible half-fix)The second row is the point: a reviewer or a later refactor might reasonably check only
create, and the test rejects that.Checks run locally:
./mvnw spotless:applythenspotless:check: clean./mvnw -q -DskipTests verify -pl <module> -am: exit 0, covering the changed module and its dependency closure rather than the whole repository./mvnw test -pl <module>: 355 tests, 0 failures, 0 errorsNo E2E case is added. ORC does have E2E configs under
connector-file-local-e2e, but every overflow here is a failure case and those configs assert that the job succeeds, so only an in-range control could go there, which the unit test already pins.Check list
incompatible-changes.mdto describe the incompatibility caused by this PR.