datafusion-remote-table 0.26.0

A DataFusion table provider for executing SQL on remote databases
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use datafusion::prelude::SessionContext;
use datafusion_remote_table::{PostgresConnectionOptions, RemoteTable};
use std::sync::Arc;

#[tokio::main]
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let options = PostgresConnectionOptions::new("localhost", 5432, "user", "password");
    let remote_table = RemoteTable::try_new(options, "select * from supported_data_types").await?;

    let ctx = SessionContext::new();
    ctx.register_table("remote_table", Arc::new(remote_table))?;

    ctx.sql("select * from remote_table").await?.show().await?;

    Ok(())
}