dgvj-work commented on code in PR #1480:
URL: https://github.com/apache/arrow-go/pull/1480#discussion_r4580283943


##########
arrow/extensions/variant.go:
##########
@@ -347,14 +352,27 @@ func isNullType(dt arrow.DataType) bool {
        return st == nil || st.ID() == arrow.NULL
 }
 
+func isUnsignedInteger(dt arrow.DataType) bool {
+       st := storageType(dt)
+       if st == nil {
+               return false
+       }
+       switch st.ID() {
+       case arrow.UINT8, arrow.UINT16, arrow.UINT32, arrow.UINT64:
+               return true
+       default:
+               return false
+       }
+}
+
 func validStruct(s *arrow.StructType) bool {
        switch s.NumFields() {
        case 1:
                f := s.Field(0)
                if f.Name == "value" {
                        return isBinary(f.Type)
                }
-               return f.Name == "typed_value" && !isNullType(f.Type)
+               return f.Name == "typed_value" && !isNullType(f.Type) && 
!isUnsignedInteger(f.Type)

Review Comment:
   A typed_value-only struct now uses the same nested check as the shape that 
also has value. `list<struct{typed_value: struct{n: struct{typed_value: 
uint32}}}>` is rejected, and there is a test for it.



##########
arrow/extensions/variant_test.go:
##########
@@ -1199,23 +1237,23 @@ func TestManyTypesShredded(t *testing.T) {
                        )},
                        arrow.Field{Name: "uint8", Type: arrow.StructOf(

Review Comment:
   Renamed them to `int16_from_uint8`, `int32_from_uint16`, and 
`int64_from_uint32`. The values still come from the unsigned Go types that need 
the wider signed column.



##########
arrow/extensions/variant.go:
##########
@@ -148,8 +148,10 @@ func NewShreddedVariantType(dt arrow.DataType) 
*VariantType {
 //  3. Must satisfy exactly one of the following:
 //     a. MUST have non-nullable field named "value" that is 
binary/largebinary/binary_view
 //     b. MUST have an nullable field named "value" that is 
binary/largebinary/binary_view
-//     and another nullable field named "typed_value" that is either a 
primitive type or
-//     a list/large_list/list_view or struct which also satisfies the 
following requirements:
+//     and another nullable field named "typed_value" that is either a 
primitive type
+//     (other than an unsigned integer) or a list/large_list/list_view or 
struct which
+//     also satisfies the following requirements. Unsigned integers are not 
valid

Review Comment:
   Removed. The parenthetical already says it.



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