You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "tilinna (via GitHub)" <gi...@apache.org> on 2026/03/11 11:58:07 UTC
[I] FileWriter.Close() unexpectedly closes the caller-provided io.Writer [arrow-go]
tilinna opened a new issue, #703:
URL: https://github.com/apache/arrow-go/issues/703
### Describe the bug, including details regarding any error messages, version, and platform.
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] FileWriter.Close() unexpectedly closes the caller-provided io.Writer and always returns nil [arrow-go]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade closed issue #703: FileWriter.Close() unexpectedly closes the caller-provided io.Writer and always returns nil
URL: https://github.com/apache/arrow-go/issues/703
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] FileWriter.Close() unexpectedly closes the caller-provided io.Writer and always returns nil [arrow-go]
Posted by "petenewcomb (via GitHub)" <gi...@apache.org>.
petenewcomb commented on issue #703:
URL: https://github.com/apache/arrow-go/issues/703#issuecomment-4290949618
Thanks for catching the improper nil return, @tilinna !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] FileWriter.Close() unexpectedly closes the caller-provided io.Writer and always returns nil [arrow-go]
Posted by "tilinna (via GitHub)" <gi...@apache.org>.
tilinna commented on issue #703:
URL: https://github.com/apache/arrow-go/issues/703#issuecomment-4258336473
Seems that I've mixed the two file writers. Here's a recap of the issues:
1) arrow-go/v18/parquet/pqarrow/file_writer.go
Should mention here that it will call Close() on the underlying io.Writer if it implements io.Closer.
```go
// Close flushes out the data and closes the file. It can be called multiple times,
// subsequent calls after the first will have no effect.
func (fw *FileWriter) Close() error {
..
}
```
2) arrow-go/v18/parquet/file/file_writer.go
Should also mention here that it will call Close() on the underlying io.Writer if it implements io.Closer.
Further, there's a bug in the Close that it will always return nil.
```go
// Close closes any open row group writer and writes the file footer. Subsequent
// calls to close will have no effect.
func (fw *Writer) Close() (err error) {
if fw.open {
..
}
return nil
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] FileWriter.Close() unexpectedly closes the caller-provided io.Writer [arrow-go]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on issue #703:
URL: https://github.com/apache/arrow-go/issues/703#issuecomment-4184822855
I'd be wary of changing the behavior at this point since it is well documented, and I wouldn't want users to suddenly start leaking file handles etc. So I'm not sure about changing the interface or changing the behavior.
Is this a significant issue that is causing a problem with a particular use case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] FileWriter.Close() unexpectedly closes the caller-provided io.Writer [arrow-go]
Posted by "tilinna (via GitHub)" <gi...@apache.org>.
tilinna commented on issue #703:
URL: https://github.com/apache/arrow-go/issues/703#issuecomment-4194483376
For me it would be enough to have it documented, so that I can work around it. Also, should fix Close() to not to always return nil. Something like this:
file_writer.go:
```go
// Close closes any open row group writer and writes the file footer. Subsequent
// calls to close will have no effect.
func (fw *Writer) Close() (err error) {
if fw.open {
..
}
return nil
}
```
=>
```go
// Close closes any open row group writer, writes the file footer, and closes the
// underlying writer if it implements io.Closer. Subsequent calls to Close will
// have no effect.
func (fw *Writer) Close() (err error) {
if fw.open {
..
}
return
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org