corgy-w opened a new pull request, #13333:
URL: https://github.com/apache/seatunnel/pull/13333

   ### What
   
   Fix the element index used when decoding a decimal list in the ORC reader.
   
   In `OrcReadStrategy#readDecimalListVector` 
(`seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/OrcReadStrategy.java`,
 around line 796) the loop was:
   
   ```java
   if (!decimalVector.isNull[offset + i]) {
       BigDecimal bigDecimal = 
decimalVector.vector[i].getHiveDecimal().bigDecimalValue();
   ```
   
   The null check used `offset + i`, but the value was read from `i`.
   
   ### Why
   
   ORC list vectors store the values of a row in a flat child vector starting 
at `listVector.offsets[rowNum]`. Whenever that offset is non-zero (second and 
later batches, or a row whose list starts later in the child vector), 
`vector[i]` points at a different element than the one whose null flag was 
checked, so the reader silently returned the wrong decimal and corrupted data. 
If `vector[i]` is null while `isNull[offset + i]` is false, the same expression 
dereferences null and throws an NPE.
   
   The fix reads `decimalVector.vector[offset + i]`, matching the null check 
and all sibling decoders in the same file (`readLongListValues`, 
`readDoubleListValues`, `readBytesListValues`, timestamp).
   
   ### How verified
   
   - Added `testReadDecimalListVectorWithNonZeroOffset` to the existing 
`OrcReadStrategyTest`. It builds a `DecimalColumnVector` of four decimals with 
a null at index 2, decodes three elements from offset 1, and asserts the result 
is `[20, null, 40]` (the elements at `offset + i`).
   - Red before the fix: the test failed with `expected: <20> but was: <10>`, 
i.e. it read index `i` instead of `offset + i`.
   - Green after the fix:
   
     ```
     ./mvnw -o -pl seatunnel-connectors-v2/connector-file/connector-file-base 
test \
       -Dtest=OrcReadStrategyTest -DfailIfNoTests=false -Dskip.spotless=true
     Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
     BUILD SUCCESS
     ```
   
   - Formatting: `./mvnw -o -q -pl 
seatunnel-connectors-v2/connector-file/connector-file-base spotless:apply` 
(clean).
   
   ### Compatibility
   
   None. One-line correctness fix in the value returned; no public API, 
configuration option, or data format change.
   
   ### Contribution
   
   Thanks for maintaining SeaTunnel. This PR contributes a focused 
data-correctness fix to the SeaTunnel ORC file reader; no linked issue exists, 
the bug was found while auditing the list decoders in this class.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to