bodduv opened a new pull request, #1137:
URL: https://github.com/apache/arrow-java/pull/1137

   ### Background
   
   `ComplexCopier.copy` does a deep-copy using a `FieldReader` from the source 
and a `FieldWriter` to write to the destination. On the read side in the 
`EXTENSIONTYPE` branch, it uses `reader.getField().getType()`  to get the 
`ArrowType` it needs to forward to `writer.writeExtension(value, type)`.  
Vector-backed extension readers (UuidReaderImpl, VariantReaderImpl) override 
getField(), so this works. Holder readers (NullableUuidHolderReaderImpl, 
NullableVariantHolderReaderImpl) on the other hand do not. 
`AbstractFieldReader.getField` throws via `fail("getField")`, so any 
ComplexCopier.copy call with a holder reader as input fails.
   
   As #1109 points out, overriding getField() on a holder reader is a simple 
fix but a holder does not have a notion of `Field`, the same way primitive (as 
opposed to extension) holder readers also have no notion of `getField()` and 
the method is not overriden.
   
   ## What's Changed
   
   `ComplexCopier` only needs the `ArrowType` here, not the whole Field. So 
this PR adds a narrower accessor for that:
   
   ```java
     default ArrowType getExtensionType() {
       return getField().getType();
     }
   ```
   
   on `ExtensionReader`. The default delegates to `getField()`, so every 
existing vector-backed extension reader keeps working unchanged. Holder readers 
override `getExtensionType()` to return `holder.type()` — the 
`ExtensionHolder.type()` method added in #892 already returns the right 
ArrowType (UuidType.INSTANCE, VariantType.INSTANCE).
   
   ComplexCopier call `reader.getExtensionType()` instead of 
`reader.getField().getType()`. The new method goes on ExtensionReader rather 
than AbstractFieldReader to sit next to the other extension-specific methods 
already there (read(ExtensionHolder), readObject(), isSet()). Adding a default 
method is source- and binary-compatible.
   
   Closes #1109 .
   


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