avantgardnerio commented on code in PR #93: URL: https://github.com/apache/arrow-ballista/pull/93#discussion_r929169110
########## ballista/rust/scheduler/src/flight_sql.rs: ########## @@ -0,0 +1,460 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use arrow_flight::flight_descriptor::DescriptorType; +use arrow_flight::flight_service_server::FlightService; +use arrow_flight::sql::server::FlightSqlService; +use arrow_flight::sql::{ + ActionClosePreparedStatementRequest, ActionCreatePreparedStatementRequest, + ActionCreatePreparedStatementResult, CommandGetCatalogs, CommandGetCrossReference, + CommandGetDbSchemas, CommandGetExportedKeys, CommandGetImportedKeys, + CommandGetPrimaryKeys, CommandGetSqlInfo, CommandGetTableTypes, CommandGetTables, + CommandPreparedStatementQuery, CommandPreparedStatementUpdate, CommandStatementQuery, + CommandStatementUpdate, SqlInfo, TicketStatementQuery, +}; +use arrow_flight::{ + FlightData, FlightDescriptor, FlightEndpoint, FlightInfo, Location, Ticket, +}; +use log::{debug, error}; +use std::collections::HashMap; +use std::sync::{Arc, Mutex}; +use std::time::Duration; +use tonic::{Response, Status, Streaming}; + +use crate::scheduler_server::event::QueryStageSchedulerEvent; +use crate::scheduler_server::SchedulerServer; +use arrow_flight::SchemaAsIpc; +use ballista_core::config::BallistaConfig; +use ballista_core::serde::protobuf; +use ballista_core::serde::protobuf::job_status; +use ballista_core::serde::protobuf::JobStatus; +use ballista_core::serde::protobuf::PhysicalPlanNode; +use datafusion::arrow; +use datafusion::arrow::datatypes::Schema; +use datafusion::arrow::ipc::writer::{IpcDataGenerator, IpcWriteOptions}; +use datafusion::logical_expr::LogicalPlan; +use datafusion_proto::protobuf::LogicalPlanNode; +use prost::Message; +use tokio::time::sleep; +use uuid::Uuid; + +pub struct FlightSqlServiceImpl { + server: SchedulerServer<LogicalPlanNode, PhysicalPlanNode>, + _statements: Arc<Mutex<HashMap<Uuid, LogicalPlan>>>, +} + +impl FlightSqlServiceImpl { + pub fn new(server: SchedulerServer<LogicalPlanNode, PhysicalPlanNode>) -> Self { + Self { + server, + _statements: Arc::new(Mutex::new(HashMap::new())), + } + } +} + +#[tonic::async_trait] +impl FlightSqlService for FlightSqlServiceImpl { + type FlightService = FlightSqlServiceImpl; + // get_flight_info + async fn get_flight_info_statement( + &self, + query: CommandStatementQuery, + _request: FlightDescriptor, + ) -> Result<Response<FlightInfo>, Status> { + debug!("Got query:\n{}", query.query); + + // Run query + let config_builder = BallistaConfig::builder(); + let config = config_builder + .build() + .map_err(|e| Status::internal(format!("Error building config: {}", e)))?; + let ctx = self + .server + .state + .session_manager + .create_session(&config) Review Comment: I'm looking at the available parameters (`CommandStatementQuery` and `FlightDescriptor`) and not finding anything that would work particularly well as a session-identifier. I assume there must be such a thing lower down at the GRPC level? Anyone know where I can find something like that? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
