Skip to content

Commit

Permalink
Fix empty container creation (#173)
Browse files Browse the repository at this point in the history
Co-authored-by: Francois <[email protected]>
  • Loading branch information
FrancoisWagner and Francois authored Feb 3, 2022
1 parent 6f2898d commit 14aa90d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions v10/container/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ func (avroWriter *Writer) WriteRecord(record AvroRecord) error {
// Write the current block to the file if it has been filled. It is
// best-practise to always call this before the underlying io.Writer is closed.
func (avroWriter *Writer) Flush() error {
// Lazily write the header if it hasn't been written yet
if !avroWriter.wroteHeader {
err := avroWriter.writeHeader(avroWriter.schema)
if err != nil {
return err
}
avroWriter.wroteHeader = true
}

if avroWriter.nextBlockRecords == 0 {
return nil
}
Expand Down

0 comments on commit 14aa90d

Please sign in to comment.