MCPcopy Create free account
hub / github.com/apache/datafusion / sql_server

Function sql_server

datafusion-examples/examples/flight/sql_server.rs:75–89  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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
75pub 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
91pub struct FlightSqlServiceImpl {
92 contexts: Arc<DashMap<String, Arc<SessionContext>>>,

Callers 1

runMethod · 0.85

Calls 3

newFunction · 0.85
initFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…