From 97dca6284e2be0819b1b143fdbc31f33ac40f672 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Sun, 22 Dec 2024 19:33:21 +0100 Subject: [PATCH] flight-sql-server: add README.md --- datafusion-flight-sql-server/README.md | 41 +++++++++++++++++++++++++ datafusion-flight-sql-server/src/lib.rs | 2 ++ 2 files changed, 43 insertions(+) create mode 100644 datafusion-flight-sql-server/README.md diff --git a/datafusion-flight-sql-server/README.md b/datafusion-flight-sql-server/README.md new file mode 100644 index 0000000..f72903e --- /dev/null +++ b/datafusion-flight-sql-server/README.md @@ -0,0 +1,41 @@ +# DataFusion Flight SQL Server + +The `datafusion-flight-sql-server` is a Flight SQL server that implements the +necessary endpoints to use DataFusion as the query engine. + +## Getting Started + +To use `datafusion-flight-sql-server` in your Rust project, run: + +```sh +$ cargo add datafusion-flight-sql-server +``` + +## Example + +Here's a basic example of setting up a Flight SQL server: + +```rust +use datafusion_flight_sql_server::service::FlightSqlService; +use datafusion::{ + execution::{ + context::SessionContext, + options::CsvReadOptions, + }, +}; + +async { + let dsn: String = "0.0.0.0:50051".to_string(); + let remote_ctx = SessionContext::new(); + remote_ctx + .register_csv("test", "./examples/test.csv", CsvReadOptions::new()) + .await.expect("Register csv"); + + FlightSqlService::new(remote_ctx.state()).serve(dsn.clone()) + .await + .expect("Run flight sql service"); + +}; +``` + +This example sets up a Flight SQL server listening on `127.0.0.1:50051`. diff --git a/datafusion-flight-sql-server/src/lib.rs b/datafusion-flight-sql-server/src/lib.rs index f7f6eac..101d335 100644 --- a/datafusion-flight-sql-server/src/lib.rs +++ b/datafusion-flight-sql-server/src/lib.rs @@ -1,3 +1,5 @@ +#![doc = include_str!("../README.md")] + pub mod service; pub mod session; pub mod state;