datafusion-remote-table

Features
- Execute SQL queries on remote databases and stream results as datafusion table provider
- Insert data into remote databases
- Support inferring schema or user specified schema
- Support pushing down filters and limit to remote databases
- Execution plan can be serialized for distributed execution
- Record batches can be transformed before outputting to next plan node
Usage
- Execute SQL queries on remote database
#[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(())
}
- Insert data into remote database
#[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, vec!["public", "test_table"]).await?;
let ctx = SessionContext::new();
ctx.register_table("remote_table", Arc::new(remote_table))?;
ctx.sql("insert into remote_table values (1, 'Tom')").await?.show().await?;
Ok(())
}
Supported databases
Thanks