zeroshade commented on code in PR #1157:
URL: https://github.com/apache/arrow-go/pull/1157#discussion_r3865677210


##########
arrow/array/union.go:
##########
@@ -1070,10 +1109,12 @@ func (b *SparseUnionBuilder) AppendValueFromString(s 
string) error {
                return nil
        }
        dec := json.NewDecoder(strings.NewReader(s))
+       dec.UseNumber()
        return b.UnmarshalOne(dec)
 }
 
 func (b *SparseUnionBuilder) UnmarshalOne(dec *json.Decoder) error {
+       dec.UseNumber()

Review Comment:
   **Blocking:** `UnmarshalOne` receives a caller-owned decoder, and 
`UseNumber` permanently changes how every later value from that decoder is 
interpreted. This makes enclosing objects key-order-dependent: for a struct 
with union field `u` and `int32` field `i`, `{"i":1.5,"u":[0,1]}` succeeds with 
a default decoder, while the equivalent `{"u":[0,1],"i":1.5}` fails because 
decoding `u` switches the shared decoder before `i` is read. The dense 
implementation has the same issue. Please preserve the type-code lexeme without 
reconfiguring the supplied decoder (for example, decode that token directly 
into `json.Number` or `RawMessage`); only internally created decoders should 
call `UseNumber`.



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