Repository: segmentio/parquet-go (go)

Issue:
How to write with nested struct
Hi Team, I'm new to this package and sorry to bother.
I was trying to write a series of data with nested struct like
```golang
type People struct {
    Name string
    Age int
}

type Nested struct {
    P []People
    F string
    GF string
}
```

and here are two issues I met:
1. how write with nested struct ? I tried to write with the following code but failed with "read error: EOF":
```golang
func main() {
	type People struct {
		Name string
		Age  int
	}

	type Nested struct {
		P  []People
		F  string
		GF string
	}
	row1 := Nested{P: []People{
		{
			Name: "Bob",
			Age:  10,
		}}}
	ods := []Nested{
		row1,
	}
	buf := new(bytes.Buffer)
	w := parquet.NewGenericWriter[Nested](buf)
	_, err := w.Write(ods)
	if err != nil {
		log.Fatal("write error: ", err)
	}
	w.Close()

	file := bytes.NewReader(buf.Bytes())
	rows, err := parquet.Read[Nested](file, file.Size())
	if err != nil {
		log.Fatal("read error: ", err)
	}

	for _, row := range rows {
		fmt.Printf("%q\n", row)
	}
}
```

2. can segmentio/parquet-go write partial fields to parquet according to a new struct? It was like I have stored a slice of data with struct 
```golang
type Nested struct {
    P []People
    F string
    GF string
}
```
and when I write to parquet I just want to store
```golang
type Nested struct {
    P []People
    F string
    // GF string         ignore GF field
}
```

sorry to bother and wondering if there is a example doc ? Thank you so much

Pull request description:
fix issue 377
Fixes #377 


Patch:
diff --git a/parquet_go18.go b/parquet_go18.go
index fa086eb..48f8685 100644
--- a/parquet_go18.go
+++ b/parquet_go18.go
@@ -28,11 +28,11 @@ func Read[T any](r io.ReaderAt, size int64, options ...ReaderOption) (rows []T,
 	rows = make([]T, file.NumRows())
 	reader := NewGenericReader[T](file, config)
 	n, err := reader.Read(rows)
-	if n < len(rows) && err == io.EOF {
-		rows, err = rows[:n], nil
+	if err == io.EOF {
+		err = nil
 	}
 	reader.Close()
-	return rows, err
+	return rows[:n], err
 }
 
 // ReadFile reads rows of the parquet file at the given path.


Test patch:
diff --git a/parquet_go18_test.go b/parquet_go18_test.go
index fd66e50..ec48c7d 100644
--- a/parquet_go18_test.go
+++ b/parquet_go18_test.go
@@ -290,7 +290,43 @@ func TestIssue368(t *testing.T) {
 	}
 }
 
-func assertRowsEqual(t *testing.T, rows1, rows2 []any) {
+func TestIssue377(t *testing.T) {
+	type People struct {
+		Name string
+		Age  int
+	}
+
+	type Nested struct {
+		P  []People
+		F  string
+		GF string
+	}
+	row1 := Nested{P: []People{
+		{
+			Name: "Bob",
+			Age:  10,
+		}}}
+	ods := []Nested{
+		row1,
+	}
+	buf := new(bytes.Buffer)
+	w := parquet.NewGenericWriter[Nested](buf)
+	_, err := w.Write(ods)
+	if err != nil {
+		t.Fatal("write error: ", err)
+	}
+	w.Close()
+
+	file := bytes.NewReader(buf.Bytes())
+	rows, err := parquet.Read[Nested](file, file.Size())
+	if err != nil {
+		t.Fatal("read error: ", err)
+	}
+
+	assertRowsEqual(t, rows, ods)
+}
+
+func assertRowsEqual[T any](t *testing.T, rows1, rows2 []T) {
 	if !reflect.DeepEqual(rows1, rows2) {
 		t.Error("rows mismatch")
 
@@ -302,7 +338,7 @@ func assertRowsEqual(t *testing.T, rows1, rows2 []any) {
 	}
 }
 
-func logRows(t *testing.T, rows []any) {
+func logRows[T any](t *testing.T, rows []T) {
 	for _, row := range rows {
 		t.Logf(". %#v\n", row)
 	}