Skip to content

Commit

Permalink
Fix segfault getting compression level for a Parquet column
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreeve committed Oct 4, 2023
1 parent 02de3c1 commit ff43047
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cpp/src/parquet/properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ class PARQUET_EXPORT ColumnProperties {

size_t max_statistics_size() const { return max_stats_size_; }

int compression_level() const { return codec_options_->compression_level; }
int compression_level() const {
if (!codec_options_) {
return ::arrow::util::kUseDefaultCompressionLevel;
}
return codec_options_->compression_level;
}

const std::shared_ptr<CodecOptions>& codec_options() const { return codec_options_; }

Expand Down
7 changes: 7 additions & 0 deletions cpp/src/parquet/properties_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ TEST(TestWriterProperties, Basics) {
ASSERT_FALSE(props->page_checksum_enabled());
}

TEST(TestWriterProperties, DefaultCompression) {
std::shared_ptr<WriterProperties> props = WriterProperties::Builder().build();

ASSERT_EQ(props->compression(ColumnPath::FromDotString("any")), Compression::UNCOMPRESSED);
ASSERT_EQ(props->compression_level(ColumnPath::FromDotString("any")), ::arrow::util::kUseDefaultCompressionLevel);
}

TEST(TestWriterProperties, AdvancedHandling) {
WriterProperties::Builder builder;
builder.compression("gzip", Compression::GZIP);
Expand Down

0 comments on commit ff43047

Please sign in to comment.