MCPcopy Create free account
hub / github.com/apache/paimon-rust / write_int_parquet_file

Function write_int_parquet_file

crates/test_utils.rs:29–55  ·  view source on GitHub ↗
(
    path: &Path,
    columns: Vec<(&str, Vec<i32>)>,
    max_row_group_size: Option<usize>,
)

Source from the content-addressed store, hash-verified

27use serde::de::DeserializeOwned;
28
29pub(crate) fn write_int_parquet_file(
30 path: &Path,
31 columns: Vec<(&str, Vec<i32>)>,
32 max_row_group_size: Option<usize>,
33) {
34 let schema = Arc::new(ArrowSchema::new(
35 columns
36 .iter()
37 .map(|(name, _)| ArrowField::new(*name, ArrowDataType::Int32, false))
38 .collect::<Vec<_>>(),
39 ));
40 let arrays: Vec<Arc<dyn Array>> = columns
41 .iter()
42 .map(|(_, values)| Arc::new(Int32Array::from(values.clone())) as Arc<dyn Array>)
43 .collect();
44 let batch = RecordBatch::try_new(schema.clone(), arrays).unwrap();
45
46 let props = max_row_group_size.map(|size| {
47 WriterProperties::builder()
48 .set_max_row_group_row_count(Some(size))
49 .build()
50 });
51 let file = File::create(path).unwrap();
52 let mut writer = ArrowWriter::try_new(file, schema, props).unwrap();
53 writer.write(&batch).unwrap();
54 writer.close().unwrap();
55}
56
57pub(crate) fn local_file_path(path: &Path) -> String {
58 let normalized = path.to_string_lossy().replace('\\', "/");

Calls 4

iterMethod · 0.45
buildMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected