mirror of
https://github.com/roapi/roapi.git
synced 2026-06-05 21:04:02 +08:00
29 lines
868 B
Rust
29 lines
868 B
Rust
#[cfg(feature = "database-postgres")]
|
|
mod postgres {
|
|
use datafusion::datasource::TableProvider;
|
|
use datafusion::prelude::SessionContext;
|
|
use std::env;
|
|
|
|
use columnq::table::TableSource;
|
|
|
|
use columnq::table::database::DatabaseLoader;
|
|
|
|
#[tokio::test]
|
|
async fn load_postgres() {
|
|
dotenvy::dotenv().ok();
|
|
if let Ok(name) = env::var("TABLE_NAME") {
|
|
let t = DatabaseLoader::Postgres
|
|
.to_mem_table(&TableSource::new(name, env::var("POSGRES_URL").unwrap()))
|
|
.unwrap();
|
|
let ctx = SessionContext::new();
|
|
let stats = t
|
|
.scan(&ctx.state(), None, &[], None)
|
|
.await
|
|
.unwrap()
|
|
.partition_statistics(None)
|
|
.unwrap();
|
|
assert!(stats.num_rows.get_value().is_some());
|
|
}
|
|
}
|
|
}
|