Skip to main content

floe_core/io/write/
mod.rs

1pub mod accepted;
2pub mod csv;
3pub mod delta;
4pub mod iceberg;
5pub mod parquet;
6pub mod parts;
7pub mod strategy;
8
9use std::path::{Path, PathBuf};
10
11use crate::FloeResult;
12
13pub fn write_error_report(
14    output_path: &Path,
15    errors_per_row: &[Option<String>],
16) -> FloeResult<PathBuf> {
17    if let Some(parent) = output_path.parent() {
18        std::fs::create_dir_all(parent)?;
19    }
20    let mut items = Vec::new();
21    for (idx, err) in errors_per_row.iter().enumerate() {
22        if let Some(err) = err {
23            items.push(format!("{{\"row_index\":{},\"errors\":{}}}", idx, err));
24        }
25    }
26    let content = format!("[{}]", items.join(","));
27    std::fs::write(output_path, content)?;
28    Ok(output_path.to_path_buf())
29}
30
31pub fn write_rejected_raw(source_path: &Path, output_path: &Path) -> FloeResult<PathBuf> {
32    if let Some(parent) = output_path.parent() {
33        std::fs::create_dir_all(parent)?;
34    }
35    std::fs::copy(source_path, output_path)?;
36    Ok(output_path.to_path_buf())
37}