Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
move test utils to their own file
  • Loading branch information
xanderbailey committed Jul 14, 2026
commit 7cd9e26835ba1f6b92cc669b98d289e10495548a
34 changes: 1 addition & 33 deletions crates/iceberg/src/arrow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,4 @@ pub mod record_batch_partition_splitter;
pub use record_batch_partition_splitter::*;

#[cfg(test)]
pub(crate) mod test_utils {
use std::fs::File;

use arrow_array::RecordBatch;
use parquet::arrow::ArrowWriter;
use parquet::basic::Compression;
use parquet::encryption::encrypt::FileEncryptionProperties;
use parquet::file::properties::WriterProperties;

/// Writes `batch` to `path` as a Parquet file encrypted with `key` and `aad_prefix`.
pub(crate) fn write_encrypted_parquet(
path: &str,
batch: &RecordBatch,
key: &[u8],
aad_prefix: Option<&[u8]>,
) {
let mut builder = FileEncryptionProperties::builder(key.to_vec());
if let Some(aad) = aad_prefix {
builder = builder.with_aad_prefix(aad.to_vec());
}
let encryption_properties = builder.build().unwrap();

let props = WriterProperties::builder()
.set_compression(Compression::SNAPPY)
.with_file_encryption_properties(encryption_properties)
.build();

let file = File::create(path).unwrap();
let mut writer = ArrowWriter::try_new(file, batch.schema(), Some(props)).unwrap();
writer.write(batch).expect("Writing batch");
writer.close().unwrap();
}
}
pub(crate) mod test_utils;
48 changes: 48 additions & 0 deletions crates/iceberg/src/arrow/test_utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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::fs::File;

use arrow_array::RecordBatch;
use parquet::arrow::ArrowWriter;
use parquet::basic::Compression;
use parquet::encryption::encrypt::FileEncryptionProperties;
use parquet::file::properties::WriterProperties;

/// Writes `batch` to `path` as a Parquet file encrypted with `key` and `aad_prefix`.
pub(crate) fn write_encrypted_parquet(
path: &str,
batch: &RecordBatch,
key: &[u8],
aad_prefix: Option<&[u8]>,
) {
let mut builder = FileEncryptionProperties::builder(key.to_vec());
if let Some(aad) = aad_prefix {
builder = builder.with_aad_prefix(aad.to_vec());
}
let encryption_properties = builder.build().unwrap();

let props = WriterProperties::builder()
.set_compression(Compression::SNAPPY)
.with_file_encryption_properties(encryption_properties)
.build();

let file = File::create(path).unwrap();
let mut writer = ArrowWriter::try_new(file, batch.schema(), Some(props)).unwrap();
writer.write(batch).expect("Writing batch");
writer.close().unwrap();
}
Loading