1use datafusion::prelude::SessionContext;
2use datafusion_remote_table::{ConnectionOptions, PostgresConnectionOptions, RemoteTable};
3use std::sync::Arc;
4
5#[tokio::main]
6pub async fn main() {
7 let options = ConnectionOptions::Postgres(PostgresConnectionOptions::new(
8 "localhost",
9 5432,
10 "user",
11 "password",
12 ));
13 let remote_table = RemoteTable::try_new(options, "SELECT * from supported_data_types", None)
14 .await
15 .unwrap();
16
17 let ctx = SessionContext::new();
18 ctx.register_table("remote_table", Arc::new(remote_table))
19 .unwrap();
20
21 ctx.sql("SELECT * from remote_table")
22 .await
23 .unwrap()
24 .show()
25 .await
26 .unwrap();
27}