-
Notifications
You must be signed in to change notification settings - Fork 485
Use write.parquet.compression-{codec,level}
#358
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9544e94
Use `write.parquet.compression-{codec,level}`
jonashaag e385e77
Cleanup
jonashaag 3e678d1
Review feedback
jonashaag 029aabe
Review feedback
jonashaag 4ea76fb
Review feedback
jonashaag 6536f8e
Update pyiceberg/io/pyarrow.py
jonashaag 809ca2e
Fixup
jonashaag 8ea5ad5
Fixup
jonashaag 517f2e8
Fixup
jonashaag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1720,13 +1720,23 @@ def write_file(table: Table, tasks: Iterator[WriteTask]) -> Iterator[DataFile]: | |
| except StopIteration: | ||
| pass | ||
|
|
||
| compression_codec = table.properties.get("write.parquet.compression-codec") | ||
| compression_level = table.properties.get("write.parquet.compression-level") | ||
| compression_options: Dict[str, Any] | ||
| if compression_codec == "uncompressed": | ||
|
jonashaag marked this conversation as resolved.
Outdated
|
||
| compression_options = {"compression": "none"} | ||
| else: | ||
|
jonashaag marked this conversation as resolved.
Outdated
|
||
| compression_options = { | ||
| "compression": compression_codec, | ||
| "compression_level": None if compression_level is None else int(compression_level), | ||
| } | ||
|
|
||
| file_path = f'{table.location()}/data/{task.generate_data_file_filename("parquet")}' | ||
| file_schema = schema_to_pyarrow(table.schema()) | ||
|
|
||
| collected_metrics: List[pq.FileMetaData] = [] | ||
| fo = table.io.new_output(file_path) | ||
| with fo.create(overwrite=True) as fos: | ||
| with pq.ParquetWriter(fos, schema=file_schema, version="1.0", metadata_collector=collected_metrics) as writer: | ||
| with pq.ParquetWriter(fos, schema=file_schema, version="1.0", **compression_options) as writer: | ||
| writer.write_table(task.df) | ||
|
|
||
| data_file = DataFile( | ||
|
|
@@ -1745,13 +1755,9 @@ def write_file(table: Table, tasks: Iterator[WriteTask]) -> Iterator[DataFile]: | |
| key_metadata=None, | ||
| ) | ||
|
|
||
| if len(collected_metrics) != 1: | ||
| # One file has been written | ||
| raise ValueError(f"Expected 1 entry, got: {collected_metrics}") | ||
|
|
||
| fill_parquet_file_metadata( | ||
| data_file=data_file, | ||
| parquet_metadata=collected_metrics[0], | ||
| parquet_metadata=writer.writer.metadata, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked this through the debugger, and this looks good. Nice change @jonashaag 👍
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also tell from the PyArrow code that it's identical :) |
||
| stats_columns=compute_statistics_plan(table.schema(), table.properties), | ||
| parquet_column_mapping=parquet_path_to_id_mapping(table.schema()), | ||
| ) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.