Skip to main content

floe_core/io/write/
mod.rs

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