use graphar_flight::{FalkorExecutor, export::export_cypher_to_iceberg};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut args = std::env::args().skip(1);
let url = args
.next()
.unwrap_or_else(|| "redis://127.0.0.1:6379".into());
let graph = args.next().unwrap_or_else(|| "demo".into());
let cypher = args
.next()
.unwrap_or_else(|| "MATCH (n) RETURN n._gar_id AS id LIMIT 100".into());
let warehouse = args.next().unwrap_or_else(|| "/tmp/knut_warehouse".into());
let table = args.next().unwrap_or_else(|| "export".into());
let mut exec = FalkorExecutor::connect(&url, &graph).await?;
let report = export_cypher_to_iceberg(&mut exec, &cypher, &warehouse, &table).await?;
println!(
"exported {} rows × {} cols → iceberg table '{table}' in {warehouse}",
report.rows, report.columns
);
Ok(())
}