Skip to content

[Go] [Parquet] pqarrow file-writer & row-group-writer tracking total & total compressed bytes - #548

Merged
zeroshade merged 4 commits into
apache:mainfrom
DuanWeiFan:pqarrow-rowgroup-total-bytes
Nov 24, 2025
Merged

[Go] [Parquet] pqarrow file-writer & row-group-writer tracking total & total compressed bytes#548
zeroshade merged 4 commits into
apache:mainfrom
DuanWeiFan:pqarrow-rowgroup-total-bytes

Conversation

@DuanWeiFan

Copy link
Copy Markdown
Contributor

Rationale for this change

As discussed in issue, pqarrow parquet writer when writing more than 1 row group, it cannot track the bytesWritten & compressedbytesWritten for closed row group.
The method RowGroupTotalCompressedBytes & RowGroupTotalBytesWritten only returns the current row group.
The ideal is to introduce TotalCompressedBytes() & TotalBytesWritten() as an enhancement for user to track all row group written bytes & compressed bytes.

What changes are included in this PR?

As part of making this change, I notice the totalCompressedBytes is not being populated correctly in row_group_writer.go.
It should follow the same approach as bytesWritten where it tracks all the closed column_writer.

Are these changes tested?

Yes. I added test cases to ensure those metrics are populated correctly

Are there any user-facing changes?

Yes. There are two new methods introduced:

  1. TotalCompressedBytes()
  2. TotalBytesWritten()

It won't impact on existing users.

@DuanWeiFan
DuanWeiFan requested a review from zeroshade as a code owner October 25, 2025 20:03
Comment thread parquet/pqarrow/file_writer.go Outdated
Comment on lines +118 to +119
fw.totalCompressedBytes += fw.rgw.TotalCompressedBytes()
fw.totalBytesWritten += fw.rgw.TotalBytesWritten()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In FileWriter.Close when we write the metadata, we should probably add the size of the metadata we write to the total bytes written, yea?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes a lot of sense! I've added that to Close() so we correctly track the last row group's bytes written

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to the Close method in file/file_writer.go specifically, inside of FlushWithFooter. Currently when we close the file, we'll cover all of the bytes except for the metadata footer which is written at the end of the file. Make sense?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay here, I was travelling for a conference last week

Comment thread parquet/pqarrow/file_writer_test.go Outdated
@zeroshade

Copy link
Copy Markdown
Member

Any updates @DuanWeiFan ?

@DuanWeiFan
DuanWeiFan force-pushed the pqarrow-rowgroup-total-bytes branch from 041eb23 to f87c85e Compare November 22, 2025 17:04
@DuanWeiFan
DuanWeiFan force-pushed the pqarrow-rowgroup-total-bytes branch from f87c85e to 032cea3 Compare November 22, 2025 17:17
@DuanWeiFan

Copy link
Copy Markdown
Contributor Author

sorry for the delay I lost track of this.
I think if we are considering the metadata (header/footer..), instead of rowGroup level, I think we would need to move
total bytes written to file/file_writer.go so it has the complete picture.

@zeroshade

Copy link
Copy Markdown
Member

All looks good now, thanks!

@zeroshade
zeroshade merged commit 4b04248 into apache:main Nov 24, 2025
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants