joellubi commented on code in PR #43234:
URL: https://github.com/apache/arrow/pull/43234#discussion_r1676375978


##########
go/arrow/extensions/bool8.go:
##########
@@ -0,0 +1,196 @@
+package extensions
+
+import (
+       "fmt"
+       "reflect"
+       "strconv"
+       "strings"
+
+       "github.com/apache/arrow/go/v17/arrow"
+       "github.com/apache/arrow/go/v17/arrow/array"
+       "github.com/apache/arrow/go/v17/arrow/memory"
+       "github.com/apache/arrow/go/v17/internal/json"
+)
+
+const ExtensionNameBool8 = "bool8"
+
+// Bool8Type represents a logical boolean that is stored using 8 bits.
+type Bool8Type struct {
+       arrow.ExtensionBase
+}
+
+func NewBool8Type() *Bool8Type {
+       return &Bool8Type{ExtensionBase: arrow.ExtensionBase{Storage: 
arrow.PrimitiveTypes.Int8}}
+}
+
+func (b *Bool8Type) ArrayType() reflect.Type { return 
reflect.TypeOf(Bool8Array{}) }
+
+func (b *Bool8Type) Deserialize(storageType arrow.DataType, data string) 
(arrow.ExtensionType, error) {
+       if data != ExtensionNameBool8 {
+               return nil, fmt.Errorf("type identifier did not match: '%s'", 
data)
+       }
+       if !arrow.TypeEqual(storageType, arrow.PrimitiveTypes.Int8) {
+               return nil, fmt.Errorf("invalid storage type for Bool8Type: 
%s", storageType.Name())
+       }
+       return NewBool8Type(), nil
+}
+
+func (b *Bool8Type) ExtensionEquals(other arrow.ExtensionType) bool {
+       return b.ExtensionName() == other.ExtensionName()
+}
+
+func (b *Bool8Type) ExtensionName() string { return ExtensionNameBool8 }
+
+func (b *Bool8Type) Serialize() string { return ExtensionNameBool8 }
+
+func (b *Bool8Type) String() string { return fmt.Sprintf("Bool8<storage=%s>", 
b.Storage) }

Review Comment:
   It looks like that's exactly what the `ExtensionBase` will fall back to if 
this is not implemented:
   ```go
   func (e *ExtensionBase) String() string { return 
fmt.Sprintf("extension_type<storage=%s>", e.Storage) }
   ```
   
   Is there a convention for overriding this when the actual extension type is 
known, or should it just fall back to the default?



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