This example shows how to wrap DataFusion with `FlightSqlService` to support connecting to a standalone DataFusion-based server with a JDBC client, using the open source "JDBC Driver for Arrow Flight SQL". To install the JDBC driver in DBeaver for example, see these instructions: https://docs.dremio.com/software/client-applications/dbeaver/ When configuring the driver, specify property "UseEncryp
()
| 73 | /// Based heavily on Ballista's implementation: https://github.com/apache/datafusion-ballista/blob/main/ballista/scheduler/src/flight_sql.rs |
| 74 | /// and the example in arrow-rs: https://github.com/apache/arrow-rs/blob/master/arrow-flight/examples/flight_sql_server.rs |
| 75 | pub async fn sql_server() -> Result<(), Box<dyn std::error::Error>> { |
| 76 | env_logger::init(); |
| 77 | let addr = "0.0.0.0:50051".parse()?; |
| 78 | let service = FlightSqlServiceImpl { |
| 79 | contexts: Default::default(), |
| 80 | statements: Default::default(), |
| 81 | results: Default::default(), |
| 82 | }; |
| 83 | info!("Listening on {addr:?}"); |
| 84 | let svc = FlightServiceServer::new(service); |
| 85 | |
| 86 | Server::builder().add_service(svc).serve(addr).await?; |
| 87 | |
| 88 | Ok(()) |
| 89 | } |
| 90 | |
| 91 | pub struct FlightSqlServiceImpl { |
| 92 | contexts: Arc<DashMap<String, Arc<SessionContext>>>, |