Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parquet Writer: Make column descriptor public on the writer #3002

Merged
merged 2 commits into from
Nov 4, 2022

Conversation

pier-oliviert
Copy link
Contributor

@pier-oliviert pier-oliviert commented Nov 2, 2022

Which issue does this PR close?

There's no issue currently, because I just had this issue this morning and decided to make a PR for it. I can open up an issue if it helps.

Rationale for this change

This is so that it's possible to gather information from the column we're about to write to. That information was already present in the column but buried inside the internal of the GenericColumnWriter.

The getter returns a reference of ColumnDescPtr.

What changes are included in this PR?

The PR is missing tests, I wasn't sure if the test would add any value/safety. I'm more than happy to provide some tests if you think it's important.

Are there any user-facing changes?

None, I believe.

@github-actions github-actions bot added the parquet Changes to the parquet crate label Nov 2, 2022
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, I'm not sure about this in particular the breaking API change. Perhaps you could expand a bit on your use-case?

@@ -473,9 +479,14 @@ impl<'a> SerializedColumnWriter<'a> {
/// optional callback to be invoked on [`Self::close`]
pub fn new(
inner: ColumnWriter<'a>,
descriptor: ColumnDescPtr,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change

@@ -488,6 +499,11 @@ impl<'a> SerializedColumnWriter<'a> {
get_typed_column_writer_mut(&mut self.inner)
}

/// Returns a clone to a [`ColumnDescPtr`]
pub fn descriptor(&self) -> ColumnDescPtr {
Copy link
Contributor

Choose a reason for hiding this comment

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

Returning &ColumnDescPtr would be more idiomatic so the caller can clone only if they need to

@pier-oliviert
Copy link
Contributor Author

pier-oliviert commented Nov 3, 2022

@tustvold Maybe it's possible to do what I'm trying to do using a different API, but currently, what I'm working on is a way for me to aggregate events that comes in from a different thread, and package data into a parquet file using the SerializedColumnWriter.

What this means, is that I have an in-memory cache that I'm holding, and then constructing the parquet file (row group) when it reaches a certain size.

Since the ColumnDescriptor is not really available, as far as I can tell, I have to basically create an index myself to figure out which column I am referring to when I call writer.next_column().

If I had the possibility to gather some kind of information from the columnWriter, it would help understand the context I'm in and avoid some bookkeeping on my side.

Does that make sense?

I apologize for the breaking change, I guess I misinterpreted what "User-facing changes" meant.

Edit: It's possible that adding a getter to the ColumnDescPtr in the GenericColumnWriter would work. I just made the change locally and I can retrieve the column description there. I believe this would remove the breaking change of the API and solve my problem, would that be an acceptable solution?

@tustvold
Copy link
Contributor

tustvold commented Nov 3, 2022

If I had the possibility to gather some kind of information from the columnWriter, it would help understand the context I'm in and avoid some bookkeeping on my side.

Makes sense 👍

I believe this would remove the breaking change of the API and solve my problem, would that be an acceptable solution?

Sounds good to me

This is so that it's possible to gather information from the column
we're about to write to. That information was already present in the
column but not publicly available.

The getter returns a reference of `ColumnDescPtr`.
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

Thank you for sticking with this 👍

@tustvold tustvold merged commit 8ca4e65 into apache:master Nov 4, 2022
@ursabot
Copy link

ursabot commented Nov 4, 2022

Benchmark runs are scheduled for baseline = 01ea8c7 and contender = 8ca4e65. 8ca4e65 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants