vigneshsiva11 commented on code in PR #9361: URL: https://github.com/apache/arrow-rs/pull/9361#discussion_r2788779941
########## parquet/tests/arrow_reader/large_string_overflow.rs: ########## @@ -0,0 +1,132 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::sync::Arc; + +use arrow_array::builder::BinaryBuilder; +use arrow_array::{ArrayRef, RecordBatch}; +use arrow_schema::{DataType, Field, Schema}; + +use parquet::arrow::arrow_reader::ParquetRecordBatchReaderBuilder; +use parquet::arrow::arrow_writer::ArrowWriter; +use parquet::basic::Encoding; +use parquet::file::properties::WriterProperties; + +use tempfile::tempfile; + +/// Number of rows written +const ROWS: usize = 1024; + +/// Size of each binary value (~3MB) +/// 1024 * 3MB ≈ 3GB total → guaranteed offset overflow for i32 +const VALUE_SIZE: usize = 3 * 1024 * 1024; + +fn make_large_binary_array() -> ArrayRef { + let mut builder = BinaryBuilder::new(); + + for _ in 0..ROWS { + let data = vec![b'a'; VALUE_SIZE]; + builder.append_value(&data); + } + + Arc::new(builder.finish()) as ArrayRef +} + +fn write_parquet_with_encoding(array: ArrayRef, encoding: Encoding) -> std::fs::File { + let schema = Arc::new(Schema::new(vec![Field::new( + "col", + DataType::Binary, + false, + )])); + + let batch = RecordBatch::try_new(schema.clone(), vec![array]).unwrap(); + + let file = tempfile().unwrap(); + + let builder = WriterProperties::builder(); + let builder = match encoding { + Encoding::RLE_DICTIONARY => builder.set_dictionary_enabled(true), + _ => builder.set_dictionary_enabled(false).set_encoding(encoding), + }; + + let props = builder.build(); + + let mut writer = ArrowWriter::try_new(file.try_clone().unwrap(), schema, Some(props)).unwrap(); + + writer.write(&batch).unwrap(); + writer.close().unwrap(); + + file +} + +#[test] +// Panics until https://github.com/apache/arrow-rs/issues/7973 is fixed Review Comment: Hi @alamb, thanks for the review! I’ve updated the PR to apply the same pattern to all tests in this file: Converted the remaining cases to use #[should_panic(expected = "byte array offset overflow")] Added a comment on each test linking to https://github.com/apache/arrow-rs/issues/7973 to document why the panic is currently expected Removed the ignored tests so all cases are explicitly asserted I’ve also reformatted the code and confirmed CI passes. Please let me know if this looks good or if you’d like any further adjustments. Thanks again! -- 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]
