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

Method get_schema

datafusion-examples/examples/flight/server.rs:51–73  ·  view source on GitHub ↗
(
        &self,
        request: Request<FlightDescriptor>,
    )

Source from the content-addressed store, hash-verified

49 type DoExchangeStream = BoxStream<'static, Result<FlightData, Status>>;
50
51 async fn get_schema(
52 &self,
53 request: Request<FlightDescriptor>,
54 ) -> Result<Response<SchemaResult>, Status> {
55 let request = request.into_inner();
56
57 let listing_options = ListingOptions::new(Arc::new(ParquetFormat::default()));
58 let table_path =
59 ListingTableUrl::parse(&request.path[0]).map_err(to_tonic_err)?;
60
61 let ctx = SessionContext::new();
62 let schema = listing_options
63 .infer_schema(&ctx.state(), &table_path)
64 .await
65 .unwrap();
66
67 let options = arrow::ipc::writer::IpcWriteOptions::default();
68 let schema_result = SchemaAsIpc::new(&schema, &options)
69 .try_into()
70 .map_err(|e: ArrowError| Status::internal(e.to_string()))?;
71
72 Ok(Response::new(schema_result))
73 }
74
75 async fn do_get(
76 &self,

Callers 1

clientFunction · 0.80

Calls 5

newFunction · 0.85
into_innerMethod · 0.45
infer_schemaMethod · 0.45
stateMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected