This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 97eba43b01 enhancement: batches_to_flight_data require a schema ref as
param. (#4665)
97eba43b01 is described below
commit 97eba43b01b1e4363995ae0a6f9874b1482fb2fc
Author: jakevin <[email protected]>
AuthorDate: Wed Aug 9 03:16:58 2023 +0800
enhancement: batches_to_flight_data require a schema ref as param. (#4665)
---
arrow-flight/examples/flight_sql_server.rs | 4 ++--
arrow-flight/src/utils.rs | 4 ++--
arrow-flight/tests/flight_sql_client_cli.rs | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/arrow-flight/examples/flight_sql_server.rs
b/arrow-flight/examples/flight_sql_server.rs
index f717d9b621..08a36bc49e 100644
--- a/arrow-flight/examples/flight_sql_server.rs
+++ b/arrow-flight/examples/flight_sql_server.rs
@@ -196,9 +196,9 @@ impl FlightSqlService for FlightSqlServiceImpl {
self.check_token(&request)?;
let batch =
Self::fake_result().map_err(|e| status!("Could not fake a result",
e))?;
- let schema = (*batch.schema()).clone();
+ let schema = batch.schema();
let batches = vec![batch];
- let flight_data = batches_to_flight_data(schema, batches)
+ let flight_data = batches_to_flight_data(schema.as_ref(), batches)
.map_err(|e| status!("Could not convert batches", e))?
.into_iter()
.map(Ok);
diff --git a/arrow-flight/src/utils.rs b/arrow-flight/src/utils.rs
index ccf1e73866..8baf5ed723 100644
--- a/arrow-flight/src/utils.rs
+++ b/arrow-flight/src/utils.rs
@@ -147,11 +147,11 @@ pub fn ipc_message_from_arrow_schema(
/// Convert `RecordBatch`es to wire protocol `FlightData`s
pub fn batches_to_flight_data(
- schema: Schema,
+ schema: &Schema,
batches: Vec<RecordBatch>,
) -> Result<Vec<FlightData>, ArrowError> {
let options = IpcWriteOptions::default();
- let schema_flight_data: FlightData = SchemaAsIpc::new(&schema,
&options).into();
+ let schema_flight_data: FlightData = SchemaAsIpc::new(schema,
&options).into();
let mut dictionaries = vec![];
let mut flight_data = vec![];
diff --git a/arrow-flight/tests/flight_sql_client_cli.rs
b/arrow-flight/tests/flight_sql_client_cli.rs
index c4ae9280c8..912bcc75a9 100644
--- a/arrow-flight/tests/flight_sql_client_cli.rs
+++ b/arrow-flight/tests/flight_sql_client_cli.rs
@@ -144,9 +144,9 @@ impl FlightSqlService for FlightSqlServiceImpl {
"part_2" => batch.slice(2, 1),
ticket => panic!("Invalid ticket: {ticket:?}"),
};
- let schema = (*batch.schema()).clone();
+ let schema = batch.schema();
let batches = vec![batch];
- let flight_data = batches_to_flight_data(schema, batches)
+ let flight_data = batches_to_flight_data(schema.as_ref(), batches)
.unwrap()
.into_iter()
.map(Ok);