This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git


The following commit(s) were added to refs/heads/main by this push:
     new e62ad74d fix(arrow/csv): append null for invalid fixed-size binary 
values (#1121)
e62ad74d is described below

commit e62ad74d19949d42c62d76f01a6dfb188eddd26d
Author: Minh Vu <[email protected]>
AuthorDate: Mon Aug 17 22:54:38 2026 +0200

    fix(arrow/csv): append null for invalid fixed-size binary values (#1121)
    
    ### Rationale for this change
    
    When a fixed-size binary value has the wrong decoded width, the CSV
    reader sets Err but does not append a value. Next then returns a record
    with no row for that field.
    
    ### What changes are included in this PR?
    
    Append a null after reporting the fixed-size binary length error so the
    record keeps the same number of rows as the other fields.
    
    ### Are these changes tested?
    
    - `go test ./arrow/csv -run TestFixedSizeBinaryParseErrorAppendsNull`
    
    ### Are there any user-facing changes?
    
    Parse failures now keep the row and expose a null value for the invalid
    field.
---
 arrow/csv/reader_test.go | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/arrow/csv/reader_test.go b/arrow/csv/reader_test.go
index 8623f70b..a940c053 100644
--- a/arrow/csv/reader_test.go
+++ b/arrow/csv/reader_test.go
@@ -219,6 +219,31 @@ func TestCSVReadInvalidFields(t *testing.T) {
        }
 }
 
+func TestFixedSizeBinaryParseErrorAppendsNull(t *testing.T) {
+       schema := arrow.NewSchema(
+               []arrow.Field{
+                       {Name: "id", Type: arrow.PrimitiveTypes.Int64},
+                       {Name: "value", Type: 
&arrow.FixedSizeBinaryType{ByteWidth: 3}},
+                       {Name: "name", Type: arrow.BinaryTypes.String},
+               },
+               nil,
+       )
+       r := csv.NewReader(strings.NewReader("1,AQ==,name\n"), schema, 
csv.WithHeader(false))
+       defer r.Release()
+
+       require.True(t, r.Next())
+       require.ErrorIs(t, r.Err(), arrow.ErrInvalid)
+
+       record := r.RecordBatch()
+       require.EqualValues(t, 1, record.NumRows())
+       for i := 0; i < int(record.NumCols()); i++ {
+               assert.Equal(t, 1, record.Column(i).Len())
+       }
+       assert.Equal(t, int64(1), record.Column(0).(*array.Int64).Value(0))
+       assert.True(t, record.Column(1).IsNull(0))
+       assert.Equal(t, "name", record.Column(2).(*array.String).Value(0))
+}
+
 func TestCSVReaderParseError(t *testing.T) {
        f := bytes.NewBufferString(`## a simple set of data: 
int64;float64;string
 0;0;str-0

Reply via email to