Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: flightsql initial support #2219

Merged
merged 21 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/glaredb/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl LocalSession {
let statements = self.sess.parse_query(text)?;
for stmt in statements {
self.sess
.prepare_statement(UNNAMED, Some(stmt), Vec::new())
.prepare_statement(UNNAMED, stmt, Vec::new())
.await?;
let prepared = self.sess.get_prepared_statement(&UNNAMED)?;
let num_fields = prepared.output_fields().map(|f| f.len()).unwrap_or(0);
Expand Down
6 changes: 5 additions & 1 deletion crates/glaredb/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use pgsrv::auth::LocalAuthenticator;
use pgsrv::handler::{ProtocolHandler, ProtocolHandlerConfig};
use protogen::gen::rpcsrv::service::execution_service_server::ExecutionServiceServer;
use protogen::gen::rpcsrv::simple::simple_service_server::SimpleServiceServer;
use rpcsrv::flight_handler::{FlightServiceServer, FlightSessionHandler};
use rpcsrv::handler::{RpcHandler, SimpleHandler};
use sqlexec::engine::{Engine, EngineStorageConfig};
use std::collections::HashMap;
Expand Down Expand Up @@ -200,10 +201,13 @@ impl ComputeServer {
self.disable_rpc_auth,
self.integration_testing,
);
let flight_handler = FlightSessionHandler::try_new(&self.engine).await?;

tokio::spawn(async move {
let mut server = Server::builder()
.trace_fn(|_| debug_span!("rpc_service_request"))
.add_service(ExecutionServiceServer::new(handler));
.add_service(ExecutionServiceServer::new(handler))
.add_service(FlightServiceServer::new(flight_handler));
tychoish marked this conversation as resolved.
Show resolved Hide resolved

// Add in the simple interface if requested.
if self.enable_simple_query_rpc {
Expand Down
5 changes: 1 addition & 4 deletions crates/pgsrv/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,7 @@ where
const UNNAMED: String = String::new();

// Parse...
if let Err(e) = session
.prepare_statement(UNNAMED, Some(stmt), Vec::new())
.await
{
if let Err(e) = session.prepare_statement(UNNAMED, stmt, Vec::new()).await {
self.send_error(e.into()).await?;
return self.ready_for_query().await;
};
Expand Down
1 change: 1 addition & 0 deletions crates/rpcsrv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ tonic = { workspace = true }
bytes = "1.4"
futures = "0.3.29"
dashmap = "5.5.0"
arrow-flight = { version = "47.0.0", features = ["flight-sql-experimental"] }
universalmind303 marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 7 additions & 0 deletions crates/rpcsrv/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use datafusion::arrow::error::ArrowError;

#[derive(Debug, thiserror::Error)]
pub enum RpcsrvError {
#[error("Invalid {0} id: {1}")]
Expand Down Expand Up @@ -53,6 +55,11 @@ pub enum RpcsrvError {

#[error("{0}")]
Internal(String),

#[error("{0}")]
ParseError(String),
#[error("{0}")]
ArrowError(ArrowError),
}

pub type Result<T, E = RpcsrvError> = std::result::Result<T, E>;
Expand Down
Loading
Loading