diff --git a/rust/arrow/Cargo.toml b/rust/arrow/Cargo.toml index 45e90aef689..04e2463d34f 100644 --- a/rust/arrow/Cargo.toml +++ b/rust/arrow/Cargo.toml @@ -50,12 +50,13 @@ chrono = "0.4" flatbuffers = "0.6" hex = "0.4" arrow-flight = { path = "../arrow-flight", optional = true } -prettytable-rs = "0.8.0" +prettytable-rs = { version = "0.8.0", optional = true } [features] simd = ["packed_simd"] flight = ["arrow-flight"] -default = ["flight"] +prettyprint = ["prettytable-rs"] +default = ["flight", "prettyprint"] [dev-dependencies] criterion = "0.3" diff --git a/rust/arrow/README.md b/rust/arrow/README.md index 40a7db4f3c1..51d4a33267c 100644 --- a/rust/arrow/README.md +++ b/rust/arrow/README.md @@ -67,13 +67,25 @@ The above script will run the `flatc` compiler and perform some adjustments to t ## SIMD (Single Instruction Multiple Data) Arrow uses the [packed_simd](https://crates.io/crates/packed_simd) crate to optimize many of the implementations in the -[compute](https://github.com/apache/arrow/tree/master/rust/arrow/src/compute) module using SIMD intrinsics. These -optimizations are enabled by the `simd` feature flag and are turned on by default, but can be disabled, for example: +[compute](https://github.com/apache/arrow/tree/master/rust/arrow/src/compute) module using SIMD intrinsics. +These optimizations are enabled by the `simd` feature flag and are turned on by default, but can be disabled, for example: ```bash cargo build --no-default-features ``` +For more features, see the Features heading below. + +## Features + +Arrow uses the following features: + +* `simd` +* `flight` which contains useful functions to convert between the Flight wire format and Arrow data +* `prettyprint` which is a utility for printing record batches + +`simd` is current disabled by default, while the other features are enabled by default. Disabling `prettyprint` might be necessary in order to compile Arrow to the `wasm32-unknown-unknown` WASM target. + # Publishing to crates.io An Arrow committer can publish this crate after an official project release has diff --git a/rust/arrow/examples/read_csv.rs b/rust/arrow/examples/read_csv.rs index fb14b4e03a1..f826028ce65 100644 --- a/rust/arrow/examples/read_csv.rs +++ b/rust/arrow/examples/read_csv.rs @@ -23,6 +23,7 @@ use std::sync::Arc; use arrow::csv; use arrow::datatypes::{DataType, Field, Schema}; use arrow::error::Result; +#[cfg(feature = "prettyprint")] use arrow::util::pretty::print_batches; fn main() -> Result<()> { @@ -35,6 +36,10 @@ fn main() -> Result<()> { let file = File::open("test/data/uk_cities.csv").unwrap(); let mut csv = csv::Reader::new(file, Arc::new(schema), false, None, 1024, None); - let batch = csv.next().unwrap().unwrap(); - print_batches(&vec![batch]) + let _batch = csv.next().unwrap().unwrap(); + #[cfg(feature = "prettyprint")] + { + print_batches(&vec![_batch]).unwrap(); + } + Ok(()) } diff --git a/rust/arrow/examples/read_csv_infer_schema.rs b/rust/arrow/examples/read_csv_infer_schema.rs index eff9dc72bc5..6ddfcc277fe 100644 --- a/rust/arrow/examples/read_csv_infer_schema.rs +++ b/rust/arrow/examples/read_csv_infer_schema.rs @@ -19,6 +19,7 @@ extern crate arrow; use arrow::csv; use arrow::error::Result; +#[cfg(feature = "prettyprint")] use arrow::util::pretty::print_batches; use std::fs::File; @@ -28,7 +29,10 @@ fn main() -> Result<()> { .has_header(true) .infer_schema(Some(100)); let mut csv = builder.build(file).unwrap(); - let batch = csv.next().unwrap().unwrap(); - - print_batches(&vec![batch]) + let _batch = csv.next().unwrap().unwrap(); + #[cfg(feature = "prettyprint")] + { + print_batches(&vec![_batch]).unwrap(); + } + Ok(()) } diff --git a/rust/arrow/src/util/mod.rs b/rust/arrow/src/util/mod.rs index 7b0dfea8956..f3bcc23a1d4 100644 --- a/rust/arrow/src/util/mod.rs +++ b/rust/arrow/src/util/mod.rs @@ -17,6 +17,7 @@ pub mod bit_util; pub mod integration_util; +#[cfg(feature = "prettyprint")] pub mod pretty; pub mod string_writer; pub mod test_util;