parquet/file: a panic recovered in WriteBatch is not kept, so Close writes a footer for rows with no values

Open
#1,693 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@EdwardShen125 is already working on this.

Since Nov 27, 2026.

  • #1694 by @EdwardShen125 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
go
Domain
backend, databases

Research direction

Start by reading the WriteBatch error recovery and Close paths for column chunk writers, then compare how FlushCurrentPage errors are saved, as referenced in issues #1597 and #1621. Reproduce the supplied example and check the resulting row count and footer behavior; done means Close returns the recovered error and no footer is written.

Written by the indexing model from the issue text.

Description

Describe the bug, including details regarding any error messages, version, and platform.

WriteBatch returns an error when it recovers a panic, but the error is not kept on the column, so every Close after it returns nil and the file ends up with a footer for rows that have no values. FlushCurrentPage errors are kept (#1597, #1621), recovered panics are not. This is the case @zeroshade noted in the #1621 review. On main:

root, _ := schema.NewGroupNode("schema", parquet.Repetitions.Required, schema.FieldList{
	schema.NewInt32Node("col", parquet.Repetitions.Optional, -1),
}, -1)
var buf bytes.Buffer
props := parquet.NewWriterProperties(parquet.WithDictionaryDefault(false))
w := file.NewParquetWriter(&buf, root, file.WithWriterProps(props))
rg := w.AppendRowGroup()
col, _ := rg.NextColumn()

_, err := col.(*file.Int32ColumnChunkWriter).WriteBatch([]int32{1}, []int16{1, 1, 1}, nil)
fmt.Println(err) // unknown error type: runtime error: slice bounds out of range [:3] with capacity 1
fmt.Println(col.Close(), rg.Close(), w.Close()) // <nil> <nil> <nil>

r, _ := file.NewParquetReader(bytes.NewReader(buf.Bytes()))
fmt.Println(r.MetaData().NumRows()) // 3; reading the column back gives 0 rows and no error

Expected: Close returns the saved error and no footer is written, same as for a FlushCurrentPage error.

Component(s)

Parquet

Dominant language
Assembly
Stars
423
Forks
188
Avg merge
1d 7h
Merged PRs (30d)
164

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/arrow-go

All issues in apache/arrow-go

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.