nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: segmentio/parquet-go
Pull request #95 (2022-03-15 14:18:40)

Fix trailing nulls in repeated pages
The equivalent of #74 for repeated pages.


Patch:
diff --git a/page.go b/page.go
index 760d327..d3f66e6 100644
--- a/page.go
+++ b/page.go
@@ -546,7 +546,7 @@ func (r *repeatedPageReader) ReadValues(values []Value) (n int, err error) {
 				r.offset++
 				n++
 			}
-			if err != nil {
+			if err != nil && err != io.EOF {
 				return n, err
 			}
 		}


Test patch:
diff --git a/page_test.go b/page_test.go
index 284a259..b0704d5 100644
--- a/page_test.go
+++ b/page_test.go
@@ -449,3 +449,43 @@ func TestOptionalPagePreserveIndex(t *testing.T) {
 		t.Errorf("wrong index: got=%d want=%d", row[0].Column(), 0)
 	}
 }
+
+func TestRepeatedPageTrailingNulls(t *testing.T) {
+	type testStruct struct {
+		A []string `parquet:"a"`
+	}
+
+	s := parquet.SchemaOf(&testStruct{})
+
+	records := []*testStruct{
+		{A: nil},
+		{A: []string{"test"}},
+		{A: nil},
+	}
+
+	buf := parquet.NewBuffer(s)
+	for _, rec := range records {
+		row := s.Deconstruct(nil, rec)
+		err := buf.WriteRow(row)
+		if err != nil {
+			t.Fatal(err)
+		}
+	}
+
+	resultRows := []parquet.Row{}
+	reader := buf.Rows()
+	for {
+		row, err := reader.ReadRow(nil)
+		if err != nil {
+			if err == io.EOF {
+				break
+			}
+			t.Fatal("reading rows:", err)
+		}
+		resultRows = append(resultRows, row)
+	}
+
+	if len(resultRows) != len(records) {
+		t.Errorf("wrong number of rows read: got=%d want=%d", len(resultRows), len(records))
+	}
+}
Repository: segmentio/parquet-go
Pull request #99 (2022-03-16 11:05:45)

Fix repeated sort func


Patch:
diff --git a/sort.go b/sort.go
index 58e236a..fdfff59 100644
--- a/sort.go
+++ b/sort.go
@@ -161,7 +161,7 @@ func sortFuncOfRepeated(sort SortFunc, config *SortConfig) SortFunc {
 	sort = sortFuncOfOptional(sort, config)
 	return func(a, b []Value) int {
 		n := len(a)
-		if n < len(b) {
+		if n > len(b) {
 			n = len(b)
 		}
 


Test patch:
diff --git a/sort_test.go b/sort_test.go
index 6804c37..3cb946a 100644
--- a/sort_test.go
+++ b/sort_test.go
@@ -4,6 +4,7 @@ import (
 	"sort"
 	"testing"
 
+	"github.com/google/uuid"
 	"github.com/segmentio/parquet-go"
 )
 
@@ -43,3 +44,39 @@ func TestSortFunc(t *testing.T) {
 		}
 	}
 }
+
+func TestRepeatedUUIDSortFunc(t *testing.T) {
+	type testStruct struct {
+		List []uuid.UUID `parquet:"list"`
+	}
+
+	s := parquet.SchemaOf(&testStruct{})
+
+	a := s.Deconstruct(nil, &testStruct{
+		List: []uuid.UUID{
+			uuid.MustParse("00000000-0000-0000-0000-000000000001"),
+			uuid.MustParse("00000000-0000-0000-0000-000000000002"),
+		},
+	})
+
+	b := s.Deconstruct(nil, &testStruct{
+		List: []uuid.UUID{
+			uuid.MustParse("00000000-0000-0000-0000-000000000001"),
+			uuid.MustParse("00000000-0000-0000-0000-000000000002"),
+			uuid.MustParse("00000000-0000-0000-0000-000000000003"),
+		},
+	})
+
+	// a and b are equal up until the third element, then a ends so a < b.
+	f := parquet.SortFuncOf(
+		s.ChildByName("list").Type(),
+		parquet.SortDescending(false),
+		parquet.SortNullsFirst(true),
+		parquet.SortMaxDefinitionLevel(1),
+		parquet.SortMaxRepetitionLevel(1),
+	)
+	cmp := f(a, b)
+	if cmp >= 0 {
+		t.Fatal("expected a < b, got compare value", cmp)
+	}
+}