Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Prettytable is unmaintained. Change to comfy-table #251

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ serde_json = { version = "^1.0", features = ["preserve_order"], optional = true
indexmap = { version = "^1.6", optional = true }

# used to print columns in a nice columnar format
prettytable-rs = { version = "^0.8", optional = true }
comfy-table = { version = "4.0", optional = true }

flatbuffers = { version = "=2.0.0", optional = true }
hex = { version = "^0.4", optional = true }
Expand Down Expand Up @@ -96,7 +96,7 @@ io_parquet_compression = [
"parquet2/brotli",
]
io_json_integration = ["io_json", "hex"]
io_print = ["prettytable-rs"]
io_print = ["comfy-table"]
# the compute kernels. Disabling this significantly reduces compile time.
compute = []
# base64 + io_ipc because arrow schemas are stored as base64-encoded ipc format.
Expand Down
11 changes: 5 additions & 6 deletions src/io/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

use crate::{array::*, error::Result, record_batch::RecordBatch};

use prettytable::format;
use prettytable::{Cell, Row, Table};
use comfy_table::{Cell, Table};

/// Returns a visual representation of multiple [`RecordBatch`]es.
pub fn write(batches: &[RecordBatch]) -> Result<String> {
Expand All @@ -27,14 +26,14 @@ pub fn write(batches: &[RecordBatch]) -> Result<String> {

/// Prints a visual representation of record batches to stdout
pub fn print(results: &[RecordBatch]) -> Result<()> {
create_table(results)?.printstd();
println!("{}", create_table(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);
Expand All @@ -46,7 +45,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 {
let displayes = batch
Expand All @@ -61,7 +60,7 @@ fn create_table(results: &[RecordBatch]) -> Result<Table> {
let string = displayes[col](row);
cells.push(Cell::new(&string));
});
table.add_row(Row::new(cells));
table.add_row(cells);
}
}

Expand Down