cxzl25 opened a new pull request, #2638:
URL: https://github.com/apache/orc/pull/2638

   ### What changes were proposed in this pull request?
   Add a `batchSize > 0` guard in `ConvertTreeReader.convertVector()` before 
accessing index 0. 
   
   ### Why are the changes needed?
   When reading an ORC file with schema evolution converting `array<int>` to 
`array<string>`, an `ArrayIndexOutOfBoundsException` is thrown if the first 
batch processed by the element reader has `childCount=0` (i.e., all rows in the 
batch contain empty arrays).
   
   ```java
   java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
        at 
org.apache.orc.impl.ConvertTreeReaderFactory$StringGroupFromAnyIntegerTreeReader.setConvertVectorElement(ConvertTreeReaderFactory.java:1094)
        at 
org.apache.orc.impl.ConvertTreeReaderFactory$ConvertTreeReader.convertVector(ConvertTreeReaderFactory.java:305)
        at 
org.apache.orc.impl.ConvertTreeReaderFactory$StringGroupFromAnyIntegerTreeReader.nextVector(ConvertTreeReaderFactory.java:1115)
        at 
org.apache.orc.impl.TreeReaderFactory$ListTreeReader.nextVector(TreeReaderFactory.java:2892)
        at 
org.apache.orc.impl.reader.tree.StructBatchReader.readBatchColumn(StructBatchReader.java:66)
        at 
org.apache.orc.impl.reader.tree.StructBatchReader.nextBatchForLevel(StructBatchReader.java:101)
        at 
org.apache.orc.impl.reader.tree.StructBatchReader.nextBatch(StructBatchReader.java:78)
        at 
org.apache.orc.impl.RecordReaderImpl.nextBatch(RecordReaderImpl.java:1444)
   ```
   
   ### How was this patch tested?
   Added `testIntArrayToStringArrayFirstBatchAllEmpty` in 
`TestConvertTreeReaderFactory`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Generated-by: Claude
   


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