#sql-database #sql-query #sql #remote #table #datafusion

datafusion-remote-table

Execute SQL queries on remote databases and make results as datafusion table provider

5 releases (breaking)

new 0.5.0 Mar 14, 2025
0.4.0 Mar 14, 2025
0.3.0 Mar 11, 2025
0.2.0 Mar 7, 2025
0.1.0 Mar 6, 2025

#1899 in Database interfaces

Download history 315/week @ 2025-03-05

315 downloads per month

MIT license

94KB
2.5K SLoC

datafusion-remote-table

License Crates.io

Goals

  1. Execute SQL queries on remote databases and make results as datafusion table provider
  2. Execution plan can be serialized for distributed execution
  3. Record batches can be transformed before outputting to next operator

Usage

#[tokio::main]
pub async fn main() {
    let options = ConnectionOptions::Postgres(PostgresConnectionOptions::new(
        "localhost",
        5432,
        "user",
        "password",
    ));
    let remote_table = RemoteTable::try_new(options, "SELECT * from supported_data_types", None)
        .await
        .unwrap();

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

    ctx.sql("SELECT * from remote_table")
        .await
        .unwrap()
        .show()
        .await
        .unwrap();
}

Supported databases

  • Postgres
  • MySQL
  • Oracle
  • SQLite

Thanks

Dependencies

~106MB
~2M SLoC