Skip to content

FileWriter.Close() unexpectedly closes the caller-provided io.Writer #703

@tilinna

Description

@tilinna

Version: github.com/apache/arrow-go/v18 v18.5.2

pqarrow.NewFileWriter accepts an io.Writer, but FileWriter.Close() internally calls TellWrapper.Close() which performs a runtime type assertion and calls Close() on the underlying writer if it satisfies io.WriteCloser.

This violates the established Go convention that a writer accepting io.Writer does not own the sink's lifetime. Both gzip.Writer and bufio.Writer write their format trailers in Close() but explicitly leave the underlying io.Writer open — the caller who created the sink is responsible for closing it.

Suggested fix: Remove the Close call from TellWrapper.Close(). If closing the underlying writer is intentional, NewFileWriter should accept io.WriteCloser explicitly so the contract is visible to callers.

Component(s)

Parquet

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions