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


##########
arrow/array/util_test.go:
##########
@@ -918,6 +918,23 @@ func 
TestRecordBuilderUnmarshalOnePreservesUserDecoderOptions(t *testing.T) {
        assert.EqualValues(t, int64(9223372036854775807), col.Value(0))
 }
 
+func TestRecordBuilderUnmarshalOneReturnUnexpectedEOF(t *testing.T) {
+       mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
+       defer mem.AssertSize(t, 0)
+
+       schema := arrow.NewSchema([]arrow.Field{
+               {Name: "a", Type: arrow.PrimitiveTypes.Int64},
+       }, nil)
+
+       bldr := array.NewRecordBuilder(mem, schema)
+       defer bldr.Release()
+
+       src := strings.NewReader(`{"a": 9`)
+       dec := json.NewDecoder(src)
+
+       assert.ErrorIs(t, bldr.UnmarshalOne(dec), io.ErrUnexpectedEOF)

Review Comment:
   nit: the bug users hit is in `JSONReader`. Consider adding a `NewJSONReader` 
case on `{"a":1}\n{"a":2` that asserts 1 row comes back and `Err()` is 
`io.ErrUnexpectedEOF`.



##########
arrow/array/record.go:
##########
@@ -607,6 +609,11 @@ func (b *RecordBuilder) unmarshalOne(dec *json.Decoder) 
(err error) {
        if delim, ok := t.(json.Delim); !ok || delim != '{' {
                return fmt.Errorf("record should start with '{', not %s", t)
        }
+       defer func() {

Review Comment:
   nit: `JSONReader.readNext` now depends on the difference between `io.EOF` 
(no record started) and `io.ErrUnexpectedEOF` (input ended inside one). Worth 
stating in the `UnmarshalOne` doc. Also, this replaces any error that wraps 
`io.EOF` with a bare sentinel, so if a wrapped error ever reaches here, its 
message is lost.



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