diff --git a/cpp/src/parquet/properties.h b/cpp/src/parquet/properties.h index bdc5b15332d09..9344181d3f82f 100644 --- a/cpp/src/parquet/properties.h +++ b/cpp/src/parquet/properties.h @@ -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& codec_options() const { return codec_options_; } diff --git a/cpp/src/parquet/properties_test.cc b/cpp/src/parquet/properties_test.cc index 96c3a63b831eb..30ea67c2766e3 100644 --- a/cpp/src/parquet/properties_test.cc +++ b/cpp/src/parquet/properties_test.cc @@ -49,6 +49,13 @@ TEST(TestWriterProperties, Basics) { ASSERT_FALSE(props->page_checksum_enabled()); } +TEST(TestWriterProperties, DefaultCompression) { + std::shared_ptr 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);