Skip to content

Commit

Permalink
replace deprecated functions in integrations tests with traits
Browse files Browse the repository at this point in the history
clippy complains about using deprecated functions, so replace them with
the new trait support.

also: fix the trait documentation
  • Loading branch information
garyanaplan committed Jun 17, 2021
1 parent ca9c8a4 commit f2568e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
6 changes: 3 additions & 3 deletions arrow-flight/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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?;

Expand Down
24 changes: 10 additions & 14 deletions integration-testing/src/flight_server_scenarios/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f2568e0

Please sign in to comment.