Skip to content

Apache DataFusion SQL Query Engine

ARROW-10801: [Rust] [Flight] Support sending FlightData for Dictionaries with that of a RecordBatch

Carol (Nichols || Goulding)334ace0b240b
diff --git a/rust/datafusion/examples/flight_server.rs b/rust/datafusion/examples/flight_server.rs
index a601b7cafd..d835ab050d 100644
--- a/rust/datafusion/examples/flight_server.rs
+++ b/rust/datafusion/examples/flight_server.rs
@@ -66,7 +66,13 @@ impl FlightService for FlightServiceImpl {
let table = ParquetTable::try_new(&request.path[0]).unwrap();
- Ok(Response::new(SchemaResult::from(table.schema().as_ref())))
+ let options = arrow::ipc::writer::IpcWriteOptions::default();
+ let schema_result = arrow_flight::utils::flight_schema_from_arrow_schema(
+ table.schema().as_ref(),
+ &options,
+ );
+
+ Ok(Response::new(schema_result))
}
async fn do_get(
@@ -108,13 +114,26 @@ impl FlightService for FlightServiceImpl {
}
// add an initial FlightData message that sends schema
+ let options = arrow::ipc::writer::IpcWriteOptions::default();
let schema = plan.schema();
+ let schema_flight_data =
+ arrow_flight::utils::flight_data_from_arrow_schema(
+ schema.as_ref(),
+ &options,
+ );
+
let mut flights: Vec<Result<FlightData, Status>> =
- vec![Ok(FlightData::from(schema.as_ref()))];
+ vec![Ok(schema_flight_data)];
let mut batches: Vec<Result<FlightData, Status>> = results
.iter()
- .map(|batch| Ok(FlightData::from(batch)))
+ .flat_map(|batch| {
+ let flight_data =
+ arrow_flight::utils::flight_data_from_arrow_batch(
+ batch, &options,
+ );
+ flight_data.into_iter().map(Ok)
+ })
.collect();
// append batch vector to schema vector, so that the first message sent is the schema