fv-plan 0.4.0

The FusionVault transform executor on Apache DataFusion: inline row steps and relational reshapes (join, aggregate, window, union) over Arrow, with the value dialect translated into the plan, spatial SQL, file sources, and build orchestration checked against the published conformance vectors.
Documentation
//! File-format sources — CSV / NDJSON / Parquet read natively by DataFusion
//! into engine rows. No extra dependencies: DataFusion ships these readers. Feeds the funnel
//! `file_lake` source and connector snapshots. Types are inferred by DataFusion and collapsed
//! to the dialect's dynamic `Value` via `convert::batch_to_rows`.

use datafusion::prelude::{CsvReadOptions, JsonReadOptions, ParquetReadOptions, SessionContext};

use crate::convert::batches_to_rows;
use crate::row::Row;

async fn collect(df: datafusion::dataframe::DataFrame) -> Result<Vec<Row>, String> {
    let batches = df.collect().await.map_err(|e| e.to_string())?;
    batches_to_rows(&batches)
}

/// Read a CSV file (header row by default) into rows.
pub async fn read_csv(path: &str, has_header: bool) -> Result<Vec<Row>, String> {
    let ctx = SessionContext::new();
    let df = ctx
        .read_csv(path, CsvReadOptions::new().has_header(has_header))
        .await
        .map_err(|e| e.to_string())?;
    collect(df).await
}

/// Read a newline-delimited JSON file into rows.
pub async fn read_ndjson(path: &str) -> Result<Vec<Row>, String> {
    let ctx = SessionContext::new();
    let df = ctx
        .read_json(path, JsonReadOptions::default())
        .await
        .map_err(|e| e.to_string())?;
    collect(df).await
}

/// Read a Parquet file into rows.
pub async fn read_parquet(path: &str) -> Result<Vec<Row>, String> {
    let ctx = SessionContext::new();
    let df = ctx
        .read_parquet(path, ParquetReadOptions::default())
        .await
        .map_err(|e| e.to_string())?;
    collect(df).await
}