pitrou commented on code in PR #48692:
URL: https://github.com/apache/arrow/pull/48692#discussion_r2715771351


##########
cpp/src/parquet/column_writer_test.cc:
##########
@@ -2463,5 +2464,84 @@ TYPED_TEST(TestBloomFilterWriter, Basic) {
   }
 }
 
+class TestArrowWriteSerialize : public ::testing::Test {
+ public:
+  void SetUp() {
+    // Create a Parquet schema
+    // Int8 maps to Int32 in Parquet with INT_8 converted type
+    auto node = schema::PrimitiveNode::Make("int8_col", Repetition::OPTIONAL, 
Type::INT32,
+                                            ConvertedType::INT_8);
+    schema_descriptor_ = std::make_shared<ColumnDescriptor>(node, 1, 0);
+    sink_ = CreateOutputStream();
+    writer_properties_ = default_writer_properties();
+  }
+
+  std::shared_ptr<TypedColumnWriter<Int32Type>> BuildWriter() {
+    metadata_ =
+        ColumnChunkMetaDataBuilder::Make(writer_properties_, 
schema_descriptor_.get());
+    std::unique_ptr<PageWriter> pager =
+        PageWriter::Open(sink_, Compression::UNCOMPRESSED, metadata_.get());
+    std::shared_ptr<ColumnWriter> writer =
+        ColumnWriter::Make(metadata_.get(), std::move(pager), 
writer_properties_.get());
+    return std::static_pointer_cast<TypedColumnWriter<Int32Type>>(writer);
+  }
+
+  std::shared_ptr<TypedColumnReader<Int32Type>> BuildReader(int64_t num_rows) {
+    EXPECT_OK_AND_ASSIGN(auto buffer, sink_->Finish());
+    auto source = std::make_shared<::arrow::io::BufferReader>(buffer);
+    ReaderProperties reader_properties;
+    std::unique_ptr<PageReader> page_reader = PageReader::Open(
+        std::move(source), num_rows, Compression::UNCOMPRESSED, 
reader_properties);
+    std::shared_ptr<ColumnReader> reader =
+        ColumnReader::Make(schema_descriptor_.get(), std::move(page_reader));
+    return std::static_pointer_cast<TypedColumnReader<Int32Type>>(reader);
+  }
+
+ protected:
+  std::shared_ptr<ColumnDescriptor> schema_descriptor_;
+  std::shared_ptr<::arrow::io::BufferOutputStream> sink_;
+  std::shared_ptr<WriterProperties> writer_properties_;
+  std::unique_ptr<ColumnChunkMetaDataBuilder> metadata_;
+};
+
+TEST_F(TestArrowWriteSerialize, AllNulls) {
+  std::shared_ptr<::arrow::Buffer> null_bitmap, data_buffer;
+  ASSERT_OK_AND_ASSIGN(null_bitmap, ::arrow::AllocateEmptyBitmap(100));
+  ASSERT_OK_AND_ASSIGN(data_buffer, ::arrow::AllocateBuffer(0));

Review Comment:
   > Hi @pitrou, please CMIIW, so for an all-null batch, the data buffer should 
either be nullptr (accepted for compatibility, even if not ideal) or have the 
correct full length. The empty buffer I used in the test is technically invalid.
   
   Yes, and if you call Validate on the array, you should get an error.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to