use polars::prelude::*;
use taxa_core::source::Source;
use taxa_sql::SqlSource;
const DSN: &str = "host=/tmp dbname=investing";
#[test]
#[ignore = "requires a live Postgres at host=/tmp dbname=investing"]
fn live_universe_snapshots() {
let query = "SELECT symbol, market_cap_usd, snapshot_date FROM universe_snapshots LIMIT 100";
let src = SqlSource::connect(DSN, query).expect("connect + ingest");
assert_eq!(src.height(), 100);
let df = src.frame().expect("frame").collect().expect("collect");
assert_eq!(df.height(), 100, "frame should have 100 rows");
let cols = src.columns().expect("columns");
for name in ["symbol", "market_cap_usd", "snapshot_date"] {
assert!(cols.contains(name), "missing column {name}");
}
let mcap_dtype = df.column("market_cap_usd").unwrap().dtype();
assert_eq!(
mcap_dtype,
&DataType::Float64,
"market_cap_usd should be Float64"
);
println!("live test OK: shape={:?}", df.shape());
println!("dtypes: {:?}", src.schema().unwrap());
println!("{}", df.head(Some(5)));
}