From f2568e00199b5e99f941e18cc07b70f35742a683 Mon Sep 17 00:00:00 2001 From: garyanaplan Date: Thu, 17 Jun 2021 09:27:26 +0100 Subject: [PATCH] replace deprecated functions in integrations tests with traits clippy complains about using deprecated functions, so replace them with the new trait support. also: fix the trait documentation --- arrow-flight/src/utils.rs | 6 ++--- .../integration_test.rs | 7 +++--- .../integration_test.rs | 24 ++++++++----------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/arrow-flight/src/utils.rs b/arrow-flight/src/utils.rs index 589c299e5aa8..658c7143cf39 100644 --- a/arrow-flight/src/utils.rs +++ b/arrow-flight/src/utils.rs @@ -76,7 +76,7 @@ pub fn flight_data_to_arrow_batch( /// Convert a `Schema` to `SchemaResult` by converting to an IPC message #[deprecated( since = "4.3.0", - note = "Use From trait, e.g.: (schema, options).into()" + note = "Use From trait, e.g.: SchemaAsIpc::new(schema, options).into()" )] pub fn flight_schema_from_arrow_schema( schema: &Schema, @@ -88,7 +88,7 @@ pub fn flight_schema_from_arrow_schema( /// Convert a `Schema` to `FlightData` by converting to an IPC message #[deprecated( since = "4.3.0", - note = "Use From trait, e.g.: (schema, options).into()" + note = "Use From trait, e.g.: SchemaAsIpc::new(schema, options).into()" )] pub fn flight_data_from_arrow_schema( schema: &Schema, @@ -100,7 +100,7 @@ pub fn flight_data_from_arrow_schema( /// Convert a `Schema` to bytes in the format expected in `FlightInfo.schema` #[deprecated( since = "4.3.0", - note = "Use TryFrom trait, e.g.: (schema, options).try_into()" + note = "Use TryFrom trait, e.g.: SchemaAsIpc::new(schema, options).try_into()" )] pub fn ipc_message_from_arrow_schema( schema: &Schema, diff --git a/integration-testing/src/flight_client_scenarios/integration_test.rs b/integration-testing/src/flight_client_scenarios/integration_test.rs index ff61b5ce2db1..a54dd04ef7c9 100644 --- a/integration-testing/src/flight_client_scenarios/integration_test.rs +++ b/integration-testing/src/flight_client_scenarios/integration_test.rs @@ -25,7 +25,8 @@ use arrow::{ }; use arrow_flight::{ flight_descriptor::DescriptorType, flight_service_client::FlightServiceClient, - utils::flight_data_to_arrow_batch, FlightData, FlightDescriptor, Location, Ticket, + utils::flight_data_to_arrow_batch, FlightData, FlightDescriptor, Location, + SchemaAsIpc, Ticket, }; use futures::{channel::mpsc, sink::SinkExt, stream, StreamExt}; use tonic::{Request, Streaming}; @@ -73,8 +74,8 @@ async fn upload_data( let (mut upload_tx, upload_rx) = mpsc::channel(10); let options = arrow::ipc::writer::IpcWriteOptions::default(); - let mut schema_flight_data = - arrow_flight::utils::flight_data_from_arrow_schema(&schema, &options); + let mut schema_flight_data: FlightData = SchemaAsIpc::new(&schema, &options).into(); + // arrow_flight::utils::flight_data_from_arrow_schema(&schema, &options); schema_flight_data.flight_descriptor = Some(descriptor.clone()); upload_tx.send(schema_flight_data).await?; diff --git a/integration-testing/src/flight_server_scenarios/integration_test.rs b/integration-testing/src/flight_server_scenarios/integration_test.rs index ee42a47c9a4c..9f8424cc5349 100644 --- a/integration-testing/src/flight_server_scenarios/integration_test.rs +++ b/integration-testing/src/flight_server_scenarios/integration_test.rs @@ -31,9 +31,10 @@ use arrow_flight::{ flight_descriptor::DescriptorType, flight_service_server::FlightService, flight_service_server::FlightServiceServer, Action, ActionType, Criteria, Empty, FlightData, FlightDescriptor, FlightEndpoint, FlightInfo, HandshakeRequest, - HandshakeResponse, PutResult, SchemaResult, Ticket, + HandshakeResponse, IpcMessage, PutResult, SchemaAsIpc, SchemaResult, Ticket, }; use futures::{channel::mpsc, sink::SinkExt, Stream, StreamExt}; +use std::convert::TryInto; use tokio::sync::Mutex; use tonic::{transport::Server, Request, Response, Status, Streaming}; @@ -111,12 +112,8 @@ impl FlightService for FlightServiceImpl { let options = arrow::ipc::writer::IpcWriteOptions::default(); - let schema = std::iter::once({ - Ok(arrow_flight::utils::flight_data_from_arrow_schema( - &flight.schema, - &options, - )) - }); + let schema = + std::iter::once(Ok(SchemaAsIpc::new(&flight.schema, &options).into())); let batches = flight .chunks @@ -179,14 +176,13 @@ impl FlightService for FlightServiceImpl { flight.chunks.iter().map(|chunk| chunk.num_rows()).sum(); let options = arrow::ipc::writer::IpcWriteOptions::default(); - let schema = arrow_flight::utils::ipc_message_from_arrow_schema( - &flight.schema, - &options, - ) - .expect( - "Could not generate schema bytes from schema stored by a DoPut; \ + let message = SchemaAsIpc::new(&flight.schema, &options) + .try_into() + .expect( + "Could not generate schema bytes from schema stored by a DoPut; \ this should be impossible", - ); + ); + let IpcMessage(schema) = message; let info = FlightInfo { schema,