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

Method do_get_fallback

datafusion-examples/examples/flight/sql_server.rs:247–282  ·  view source on GitHub ↗
(
        &self,
        _request: Request<Ticket>,
        message: Any,
    )

Source from the content-addressed store, hash-verified

245 }
246
247 async fn do_get_fallback(
248 &self,
249 _request: Request<Ticket>,
250 message: Any,
251 ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> {
252 if !message.is::<FetchResults>() {
253 Err(Status::unimplemented(format!(
254 "do_get: The defined request is invalid: {}",
255 message.type_url
256 )))?
257 }
258
259 let fr: FetchResults = message
260 .unpack()
261 .map_err(|e| Status::internal(format!("{e:?}")))?
262 .ok_or_else(|| Status::internal("Expected FetchResults but got None!"))?;
263
264 let handle = fr.handle;
265
266 info!("getting results for {handle}");
267 let result = self.get_result(&handle)?;
268 // if we get an empty result, create an empty schema
269 let (schema, batches) = match result.first() {
270 None => (Arc::new(Schema::empty()), vec![]),
271 Some(batch) => (batch.schema(), result.clone()),
272 };
273
274 let batch_stream = futures::stream::iter(batches).map(Ok);
275
276 let stream = FlightDataEncoderBuilder::new()
277 .with_schema(schema)
278 .build(batch_stream)
279 .map_err(Status::from);
280
281 Ok(Response::new(Box::pin(stream)))
282 }
283
284 async fn get_flight_info_prepared_statement(
285 &self,

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
emptyFunction · 0.50
get_resultMethod · 0.45
firstMethod · 0.45
schemaMethod · 0.45
cloneMethod · 0.45
mapMethod · 0.45
buildMethod · 0.45
with_schemaMethod · 0.45

Tested by

no test coverage detected