Skip to content

Commit

Permalink
Update arrow-flight subcrates (apache#3044)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Nov 8, 2022
1 parent fe3318b commit 86927b3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
5 changes: 4 additions & 1 deletion arrow-flight/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ repository = "https://github.com/apache/arrow-rs"
license = "Apache-2.0"

[dependencies]
arrow = { path = "../arrow", version = "26.0.0", default-features = false, features = ["ipc"] }
arrow-array = { version = "26.0.0", path = "../arrow-array" }
arrow-buffer = { version = "26.0.0", path = "../arrow-buffer" }
arrow-ipc = { version = "26.0.0", path = "../arrow-ipc" }
arrow-schema = { version = "26.0.0", path = "../arrow-schema" }
base64 = { version = "0.13", default-features = false }
tonic = { version = "0.8", default-features = false, features = ["transport", "codegen", "prost"] }
bytes = { version = "1", default-features = false }
Expand Down
13 changes: 7 additions & 6 deletions arrow-flight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@

#![allow(rustdoc::invalid_html_tags)]

use arrow::datatypes::Schema;
use arrow::error::{ArrowError, Result as ArrowResult};
use arrow::ipc::{convert, writer, writer::EncodedData, writer::IpcWriteOptions};
use arrow_ipc::{convert, writer, writer::EncodedData, writer::IpcWriteOptions};
use arrow_schema::{ArrowError, Schema};

use arrow::ipc::convert::try_schema_from_ipc_buffer;
use arrow_ipc::convert::try_schema_from_ipc_buffer;
use std::{
convert::{TryFrom, TryInto},
fmt,
ops::Deref,
};

type ArrowResult<T> = std::result::Result<T, ArrowError>;

#[allow(clippy::derive_partial_eq_without_eq)]

mod gen {
Expand Down Expand Up @@ -399,8 +400,8 @@ impl<'a> SchemaAsIpc<'a> {
#[cfg(test)]
mod tests {
use super::*;
use arrow::datatypes::{DataType, Field, TimeUnit};
use arrow::ipc::MetadataVersion;
use arrow_ipc::MetadataVersion;
use arrow_schema::{DataType, Field, TimeUnit};

struct TestVector(Vec<u8>, usize);

Expand Down
2 changes: 1 addition & 1 deletion arrow-flight/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use arrow::error::{ArrowError, Result as ArrowResult};
use arrow_schema::ArrowError;
use prost::Message;

mod gen {
Expand Down
2 changes: 1 addition & 1 deletion arrow-flight/src/sql/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,6 @@ fn decode_error_to_status(err: prost::DecodeError) -> Status {
Status::invalid_argument(format!("{:?}", err))
}

fn arrow_error_to_status(err: arrow::error::ArrowError) -> Status {
fn arrow_error_to_status(err: arrow_schema::ArrowError) -> Status {
Status::internal(format!("{:?}", err))
}
19 changes: 8 additions & 11 deletions arrow-flight/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
use crate::{FlightData, IpcMessage, SchemaAsIpc, SchemaResult};
use std::collections::HashMap;

use arrow::array::ArrayRef;
use arrow::buffer::Buffer;
use arrow::datatypes::{Schema, SchemaRef};
use arrow::error::{ArrowError, Result};
use arrow::ipc::{reader, writer, writer::IpcWriteOptions};
use arrow::record_batch::RecordBatch;
use std::convert::TryInto;
use arrow_array::{ArrayRef, RecordBatch};
use arrow_buffer::Buffer;
use arrow_ipc::{reader, writer, writer::IpcWriteOptions};
use arrow_schema::{ArrowError, Schema, SchemaRef};

/// Convert a `RecordBatch` to a vector of `FlightData` representing the bytes of the dictionaries
/// and a `FlightData` representing the bytes of the batch's values
Expand All @@ -52,9 +49,9 @@ pub fn flight_data_to_arrow_batch(
data: &FlightData,
schema: SchemaRef,
dictionaries_by_id: &HashMap<i64, ArrayRef>,
) -> Result<RecordBatch> {
) -> Result<RecordBatch, ArrowError> {
// check that the data_header is a record batch message
let message = arrow::ipc::root_as_message(&data.data_header[..]).map_err(|err| {
let message = arrow_ipc::root_as_message(&data.data_header[..]).map_err(|err| {
ArrowError::ParseError(format!("Unable to get root as message: {:?}", err))
})?;

Expand Down Expand Up @@ -85,7 +82,7 @@ pub fn flight_data_to_arrow_batch(
pub fn flight_schema_from_arrow_schema(
schema: &Schema,
options: &IpcWriteOptions,
) -> Result<SchemaResult> {
) -> Result<SchemaResult, ArrowError> {
SchemaAsIpc::new(schema, options).try_into()
}

Expand All @@ -109,7 +106,7 @@ pub fn flight_data_from_arrow_schema(
pub fn ipc_message_from_arrow_schema(
schema: &Schema,
options: &IpcWriteOptions,
) -> Result<Vec<u8>> {
) -> Result<Vec<u8>, ArrowError> {
let message = SchemaAsIpc::new(schema, options).try_into()?;
let IpcMessage(vals) = message;
Ok(vals)
Expand Down

0 comments on commit 86927b3

Please sign in to comment.