This is an automated email from the ASF dual-hosted git repository.
alamb 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 3fa6fcd Change to comfy-table from prettytable-rs (#656)
3fa6fcd is described below
commit 3fa6fcdbc09542343fb42a2b5b6c5bbe2e56c125
Author: Chojan Shang <[email protected]>
AuthorDate: Tue Aug 17 05:11:05 2021 +0800
Change to comfy-table from prettytable-rs (#656)
* Change to comfy-table
Signed-off-by: Chojan Shang <[email protected]>
* Apply review
Signed-off-by: Chojan Shang <[email protected]>
---
arrow/Cargo.toml | 4 ++--
arrow/src/util/pretty.rs | 19 +++++++++----------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/arrow/Cargo.toml b/arrow/Cargo.toml
index 0c8ca76..cadd4ff 100644
--- a/arrow/Cargo.toml
+++ b/arrow/Cargo.toml
@@ -49,7 +49,7 @@ packed_simd = { version = "0.3", optional = true, package =
"packed_simd_2" }
chrono = "0.4"
flatbuffers = { version = "=2.0.0", optional = true }
hex = "0.4"
-prettytable-rs = { version = "0.8.0", optional = true }
+comfy-table = { version = "4.0", optional = true, default-features = false }
lexical-core = "^0.7"
multiversion = "0.6.1"
bitflags = "1.2.1"
@@ -60,7 +60,7 @@ avx512 = []
csv = ["csv_crate"]
ipc = ["flatbuffers"]
simd = ["packed_simd"]
-prettyprint = ["prettytable-rs"]
+prettyprint = ["comfy-table"]
# The test utils feature enables code used in benchmarks and tests but
# not the core arrow code itself. Be aware that `rand` must be kept as
# an optional dependency for supporting compile to wasm32-unknown-unknown
diff --git a/arrow/src/util/pretty.rs b/arrow/src/util/pretty.rs
index f959944..28bb016 100644
--- a/arrow/src/util/pretty.rs
+++ b/arrow/src/util/pretty.rs
@@ -20,8 +20,7 @@
use crate::{array::ArrayRef, record_batch::RecordBatch};
-use prettytable::format;
-use prettytable::{Cell, Row, Table};
+use comfy_table::{Cell, Table};
use crate::error::Result;
@@ -39,20 +38,20 @@ pub fn pretty_format_columns(col_name: &str, results:
&[ArrayRef]) -> Result<Str
///! Prints a visual representation of record batches to stdout
pub fn print_batches(results: &[RecordBatch]) -> Result<()> {
- create_table(results)?.printstd();
+ println!("{}", create_table(results)?);
Ok(())
}
///! Prints a visual representation of a list of column to stdout
pub fn print_columns(col_name: &str, results: &[ArrayRef]) -> Result<()> {
- create_column(col_name, results)?.printstd();
+ println!("{}", create_column(col_name, results)?);
Ok(())
}
///! Convert a series of record batches into a table
fn create_table(results: &[RecordBatch]) -> Result<Table> {
let mut table = Table::new();
- table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
+ table.load_preset("||--+-++| ++++++");
if results.is_empty() {
return Ok(table);
@@ -64,7 +63,7 @@ fn create_table(results: &[RecordBatch]) -> Result<Table> {
for field in schema.fields() {
header.push(Cell::new(&field.name()));
}
- table.set_titles(Row::new(header));
+ table.set_header(header);
for batch in results {
for row in 0..batch.num_rows() {
@@ -73,7 +72,7 @@ fn create_table(results: &[RecordBatch]) -> Result<Table> {
let column = batch.column(col);
cells.push(Cell::new(&array_value_to_string(&column, row)?));
}
- table.add_row(Row::new(cells));
+ table.add_row(cells);
}
}
@@ -82,19 +81,19 @@ fn create_table(results: &[RecordBatch]) -> Result<Table> {
fn create_column(field: &str, columns: &[ArrayRef]) -> Result<Table> {
let mut table = Table::new();
- table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
+ table.load_preset("||--+-++| ++++++");
if columns.is_empty() {
return Ok(table);
}
let header = vec![Cell::new(field)];
- table.set_titles(Row::new(header));
+ table.set_header(header);
for col in columns {
for row in 0..col.len() {
let cells = vec![Cell::new(&array_value_to_string(&col, row)?)];
- table.add_row(Row::new(cells));
+ table.add_row(cells);
}
}