luoyuxia opened a new issue, #8133:
URL: https://github.com/apache/paimon/issues/8133

   ## Summary
   
   `Arrow2PaimonVectorConverter` in `paimon-arrow` has three bugs when 
converting Arrow vectors to Paimon column vectors.
   
   ## Bug 1: `LocalZonedTimestampType` — ClassCastException
   
   In `visit(LocalZonedTimestampType)`:
   ```java
   long value = (long) vector.getObject(i);
   ```
   For timezone-unaware `TimeStampVector` (e.g., `TimeStampMilliVector`), 
`getObject(i)` returns `LocalDateTime`, not `Long`. This causes:
   ```
   java.lang.ClassCastException: class java.time.LocalDateTime cannot be cast 
to class java.lang.Long
   ```
   
   **Fix:** Read the raw long value directly from the data buffer:
   ```java
   long value = vector.getDataBuffer().getLong((long) i * 
TimeStampVector.TYPE_WIDTH);
   ```
   
   ## Bug 2: `TimeType` — ClassCastException for non-milli time vectors
   
   In `visit(TimeType)`:
   ```java
   return ((TimeMilliVector) vector).get(index);
   ```
   This hardcodes `TimeMilliVector`, but the Arrow vector may be 
`TimeMicroVector`, `TimeNanoVector`, or `TimeSecVector` depending on precision. 
This causes `ClassCastException` for non-millisecond time types.
   
   **Fix:** Use `instanceof` to handle all four time vector types and convert 
to milliseconds accordingly.
   
   ## Bug 3: `BinaryType` — wrong vector type
   
   In `visit(BinaryType)`:
   ```java
   byte[] bytes = ((VarBinaryVector) vector).getObject(index);
   ```
   `BinaryType` (fixed-length binary) corresponds to Arrow's 
`FixedSizeBinaryVector`, not `VarBinaryVector`.
   
   **Fix:** Use `FixedSizeBinaryVector` instead:
   ```java
   byte[] bytes = ((FixedSizeBinaryVector) vector).get(index);
   ```


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