You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "emkornfield (via GitHub)" <gi...@apache.org> on 2024/01/22 21:41:36 UTC
Re: [PR] GH-39527: [C++][Parquet] Validate page sizes before truncating to int32 [arrow]
emkornfield commented on code in PR #39528:
URL: https://github.com/apache/arrow/pull/39528#discussion_r1462454654
##########
cpp/src/parquet/column_writer_test.cc:
##########
@@ -889,6 +891,44 @@ TEST_F(TestByteArrayValuesWriter, CheckDefaultStats) {
ASSERT_TRUE(this->metadata_is_stats_set());
}
+TEST(TestPageWriter, ThrowsOnPagesTooLarge) {
+ NodePtr item = schema::Int32("item"); // optional item
+ NodePtr list(GroupNode::Make("b", Repetition::REPEATED, {item}, ConvertedType::LIST));
+ NodePtr bag(GroupNode::Make("bag", Repetition::OPTIONAL, {list})); // optional list
+ std::vector<NodePtr> fields = {bag};
+ NodePtr root = GroupNode::Make("schema", Repetition::REPEATED, fields);
+
+ SchemaDescriptor schema;
+ schema.Init(root);
+
+ auto sink = CreateOutputStream();
+ auto props = WriterProperties::Builder().build();
+
+ auto metadata = ColumnChunkMetaDataBuilder::Make(props, schema.Column(0));
+ std::unique_ptr<PageWriter> pager =
+ PageWriter::Open(sink, Compression::UNCOMPRESSED,
+ Codec::UseDefaultCompressionLevel(), metadata.get());
+
+ uint8_t data;
+ std::shared_ptr<Buffer> buffer =
+ std::make_shared<Buffer>(&data, std::numeric_limits<int32_t>::max() + int64_t{1});
+ DataPageV1 over_compressed_limit(buffer, /*num_values=*/100, Encoding::BIT_PACKED,
+ Encoding::BIT_PACKED, Encoding::BIT_PACKED,
+ /*uncompressed_size=*/100);
+ EXPECT_THROW(pager->WriteDataPage(over_compressed_limit), ParquetException);
Review Comment:
done.
##########
cpp/src/parquet/column_writer.cc:
##########
@@ -288,6 +291,9 @@ class SerializedPageWriter : public PageWriter {
dict_page_header.__set_is_sorted(page.is_sorted());
const uint8_t* output_data_buffer = compressed_data->data();
+ if (compressed_data->size() > std::numeric_limits<int32_t>::max()) {
+ throw ParquetException("Compressed page size overflows to INT32_MAX.");
Review Comment:
done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org