(&self)
| 96 | |
| 97 | impl FlightSqlServiceImpl { |
| 98 | async fn create_ctx(&self) -> Result<String, Status> { |
| 99 | let uuid = Uuid::new_v4().hyphenated().to_string(); |
| 100 | let session_config = SessionConfig::from_env() |
| 101 | .map_err(|e| Status::internal(format!("Error building plan: {e}")))? |
| 102 | .with_information_schema(true); |
| 103 | let ctx = Arc::new(SessionContext::new_with_config(session_config)); |
| 104 | |
| 105 | // Convert the CSV input into a temporary Parquet directory for querying |
| 106 | let dataset = ExampleDataset::Cars; |
| 107 | let parquet_temp = write_csv_to_parquet(&ctx, &dataset.path()) |
| 108 | .await |
| 109 | .map_err(|e| status!("Error writing csv to parquet", e))?; |
| 110 | let parquet_path = parquet_temp |
| 111 | .path_str() |
| 112 | .map_err(|e| status!("Error getting parquet path", e))?; |
| 113 | |
| 114 | // register parquet file with the execution context |
| 115 | ctx.register_parquet("cars", parquet_path, ParquetReadOptions::default()) |
| 116 | .await |
| 117 | .map_err(|e| status!("Error registering table", e))?; |
| 118 | |
| 119 | self.contexts.insert(uuid.clone(), ctx); |
| 120 | Ok(uuid) |
| 121 | } |
| 122 | |
| 123 | fn get_ctx<T>(&self, req: &Request<T>) -> Result<Arc<SessionContext>, Status> { |
| 124 | // get the token from the authorization header on Request |
no test coverage detected