zeroshade commented on code in PR #34631:
URL: https://github.com/apache/arrow/pull/34631#discussion_r1158680074


##########
go/parquet/pqarrow/column_readers.go:
##########
@@ -543,21 +543,26 @@ func transferBinary(rdr file.RecordReader, dt 
arrow.DataType) *arrow.Chunked {
                return transferDictionary(brdr, 
&arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Int32, ValueType: dt})
        }
        chunks := brdr.GetBuilderChunks()
-       if dt == arrow.BinaryTypes.String || dt == 
arrow.BinaryTypes.LargeString {
-               // convert chunks from binary to string without copying data,
-               // just changing the interpretation of the metadata
-               for idx := range chunks {
-                       chunks[idx] = array.MakeFromData(chunks[idx].Data())
-                       defer chunks[idx].Data().Release()
-                       defer chunks[idx].Release()
-               }
-       } else if dt.ID() == arrow.EXTENSION && len(chunks) > 0 && 
arrow.StorageTypeEqual(chunks[0].DataType(), dt) && 
!arrow.TypeEqual(chunks[0].DataType(), dt) {
-               // convert chunks from the underlying storage type to extension 
type without copying data
-               etype := dt.(arrow.ExtensionType)
-
-               for idx := range chunks {
-                       chunks[idx] = array.NewExtensionArrayWithStorage(etype, 
chunks[idx])
-                       defer chunks[idx].Release()
+       storage := dt
+       if dt.ID() == arrow.EXTENSION {
+               storage = dt.(arrow.ExtensionType).StorageType()
+       }
+       if storage == arrow.BinaryTypes.String || storage == 
arrow.BinaryTypes.LargeString || dt.ID() == arrow.EXTENSION {

Review Comment:
   why is the `dt.ID() == arrow.EXTENSION` needed?



##########
go/arrow/array/table_test.go:
##########
@@ -157,7 +157,13 @@ func TestChunkedInvalid(t *testing.T) {
                if e == nil {
                        t.Fatalf("expected a panic")
                }
-               if got, want := e.(string), "arrow/array: mismatch data type 
float64 vs int32"; got != want {
+               errStr, ok := e.(string)
+               if !ok {
+                       err := e.(error)
+                       errStr = err.Error()
+               }
+
+               if got, want := errStr, fmt.Sprintf("%s: arrow/array: mismatch 
data type float64 vs int32", arrow.ErrInvalid); got != want {

Review Comment:
   since we're expecting an error, this should probably be:
   
   ```go
   err, ok := e.(error)
   if !ok {
       t.Fatalf("expected an error")
   }
   
   if !errors.Is(err, arrow.ErrInvalid) {
       t.Fatalf("should be an ErrInvalid")
   }
   
   if got, want := err.Error(), fmt.Sprintf(........); got != want { ...
   ```



##########
go/internal/types/extension_types.go:
##########
@@ -209,13 +209,13 @@ func (UUIDType) ExtensionName() string { return "uuid" }
 func (UUIDType) Serialize() string { return "uuid-serialized" }
 
 // Deserialize expects storageType to be FixedSizeBinaryType{ByteWidth: 16} 
and the data to be
-// "uuid-serialized" in order to correctly create a UuidType for testing 
deserialize.
+// "uuid-serialized" in order to correctly create a UUIDType for testing 
deserialize.
 func (UUIDType) Deserialize(storageType arrow.DataType, data string) 
(arrow.ExtensionType, error) {
        if string(data) != "uuid-serialized" {
                return nil, fmt.Errorf("type identifier did not match: '%s'", 
string(data))
        }
-       if !arrow.TypeEqual(storageType, &arrow.FixedSizeBinaryType{ByteWidth: 
16}) {
-               return nil, fmt.Errorf("invalid storage type for UuidType: %s", 
storageType.Name())
+       if !storageTypeEqual(storageType, &arrow.FixedSizeBinaryType{ByteWidth: 
16}) {

Review Comment:
   what's the use case where an `ExtensionType` gets passed in here? If an 
`ExtensionType` is being passed in here, that means something is calling 
`Deserialize` incorrectly.



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