chore(security): Replace prettytable with comfy-table (#2905)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/24376/head
Andrew Lamb 2021-10-20 06:44:36 -04:00 committed by GitHub
parent ce0127a1f7
commit 9974a5364c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 66 additions and 164 deletions

View File

@ -1,10 +1,5 @@
[advisories]
ignore = [
# title: term is looking for a new maintainer
# why needed: used by `prettytable-rs` which is directly used by IOx but also by arrow
# upstream issue: https://github.com/phsym/prettytable-rs/issues/119
"RUSTSEC-2018-0015",
# title: Potential segfault in the time crate
# why needed: used by `chrono`
# upstream issue: https://github.com/chronotope/chrono/issues/553

149
Cargo.lock generated
View File

@ -35,7 +35,7 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom 0.2.3",
"getrandom",
"once_cell",
"version_check",
]
@ -94,12 +94,6 @@ version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1"
[[package]]
name = "arrayref"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "arrayvec"
version = "0.4.12"
@ -109,12 +103,6 @@ dependencies = [
"nodrop",
]
[[package]]
name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "arrow"
version = "6.0.0"
@ -163,9 +151,9 @@ dependencies = [
"ahash",
"arrow",
"chrono",
"comfy-table",
"hashbrown",
"num-traits",
"prettytable-rs",
"rand",
"snafu",
]
@ -253,7 +241,7 @@ dependencies = [
"chrono",
"dyn-clone",
"futures",
"getrandom 0.2.3",
"getrandom",
"http",
"log",
"oauth2",
@ -361,17 +349,6 @@ dependencies = [
"wyz",
]
[[package]]
name = "blake2b_simd"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"
dependencies = [
"arrayref",
"arrayvec 0.5.2",
"constant_time_eq",
]
[[package]]
name = "block-buffer"
version = "0.7.3"
@ -627,12 +604,6 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "constant_time_eq"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]]
name = "core-foundation"
version = "0.9.2"
@ -920,17 +891,6 @@ dependencies = [
"generic-array 0.14.4",
]
[[package]]
name = "dirs"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901"
dependencies = [
"libc",
"redox_users 0.3.5",
"winapi",
]
[[package]]
name = "dirs"
version = "4.0.0"
@ -957,7 +917,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
dependencies = [
"libc",
"redox_users 0.4.0",
"redox_users",
"winapi",
]
@ -968,7 +928,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users 0.4.0",
"redox_users",
"winapi",
]
@ -996,12 +956,6 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "encode_unicode"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]]
name = "encoding_rs"
version = "0.8.29"
@ -1306,17 +1260,6 @@ dependencies = [
"version_check",
]
[[package]]
name = "getrandom"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
"cfg-if",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]]
name = "getrandom"
version = "0.2.3"
@ -1326,7 +1269,7 @@ dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
"wasi",
"wasm-bindgen",
]
@ -1647,10 +1590,11 @@ dependencies = [
"bytes",
"chrono",
"clap",
"comfy-table",
"csv",
"data_types",
"datafusion 0.1.0",
"dirs 4.0.0",
"dirs",
"dotenv",
"entry",
"flate2",
@ -1688,7 +1632,6 @@ dependencies = [
"pprof",
"predicate",
"predicates",
"prettytable-rs",
"prost",
"query",
"rand",
@ -2432,7 +2375,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465"
dependencies = [
"arrayvec 0.4.12",
"arrayvec",
"itoa",
]
@ -2519,7 +2462,7 @@ checksum = "80e47cfc4c0a1a519d9a025ebfbac3a2439d1b5cdf397d72dcb79b11d9920dab"
dependencies = [
"base64 0.13.0",
"chrono",
"getrandom 0.2.3",
"getrandom",
"http",
"rand",
"reqwest",
@ -2719,7 +2662,7 @@ dependencies = [
"cfg-if",
"instant",
"libc",
"redox_syscall 0.2.10",
"redox_syscall",
"smallvec",
"winapi",
]
@ -3106,20 +3049,6 @@ dependencies = [
"termtree",
]
[[package]]
name = "prettytable-rs"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fd04b170004fa2daccf418a7f8253aaf033c27760b5f225889024cf66d7ac2e"
dependencies = [
"atty",
"csv",
"encode_unicode",
"lazy_static",
"term",
"unicode-width",
]
[[package]]
name = "proc-macro-crate"
version = "1.1.0"
@ -3360,7 +3289,7 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
"getrandom 0.2.3",
"getrandom",
]
[[package]]
@ -3470,12 +3399,6 @@ dependencies = [
"test_helpers",
]
[[package]]
name = "redox_syscall"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]]
name = "redox_syscall"
version = "0.2.10"
@ -3485,25 +3408,14 @@ dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
dependencies = [
"getrandom 0.1.16",
"redox_syscall 0.1.57",
"rust-argon2",
]
[[package]]
name = "redox_users"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
dependencies = [
"getrandom 0.2.3",
"redox_syscall 0.2.10",
"getrandom",
"redox_syscall",
]
[[package]]
@ -3686,18 +3598,6 @@ dependencies = [
"tokio",
]
[[package]]
name = "rust-argon2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb"
dependencies = [
"base64 0.13.0",
"blake2b_simd",
"constant_time_eq",
"crossbeam-utils",
]
[[package]]
name = "rustc-demangle"
version = "0.1.21"
@ -4263,22 +4163,11 @@ dependencies = [
"cfg-if",
"libc",
"rand",
"redox_syscall 0.2.10",
"redox_syscall",
"remove_dir_all",
"winapi",
]
[[package]]
name = "term"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42"
dependencies = [
"byteorder",
"dirs 1.0.5",
"winapi",
]
[[package]]
name = "termcolor"
version = "1.1.2"
@ -4873,7 +4762,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
dependencies = [
"getrandom 0.2.3",
"getrandom",
"serde",
]
@ -4925,12 +4814,6 @@ dependencies = [
"try-lock",
]
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"

View File

@ -142,7 +142,7 @@ itertools = "0.10.1"
parquet = "6.0"
pin-project = "1.0"
# used by arrow/datafusion anyway
prettytable-rs = "0.8"
comfy-table = { version = "4.0", default-features = false }
pprof = { version = "^0.5", default-features = false, features = ["flamegraph", "protobuf"], optional = true }
prost = "0.8"
rustyline = { version = "9.0", default-features = false }

View File

@ -14,7 +14,7 @@ snafu = "0.6"
hashbrown = "0.11"
# used by arrow anyway (needed for printing workaround)
chrono = "0.4"
prettytable-rs = "0.8"
comfy-table = { version = "4.0", default-features = false }
[dev-dependencies]
rand = "0.8.3"

View File

@ -3,8 +3,7 @@ use arrow::datatypes::{DataType, TimeUnit};
use arrow::error::Result;
use arrow::record_batch::RecordBatch;
use prettytable::format;
use prettytable::{Cell, Row, Table};
use comfy_table::{Cell, Table};
use chrono::prelude::*;
@ -54,7 +53,7 @@ fn array_value_to_string(column: &ArrayRef, row: usize) -> Result<String> {
/// NB: COPIED FROM ARROW
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);
@ -66,7 +65,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() {
@ -75,7 +74,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);
}
}

View File

@ -511,7 +511,7 @@ mod tests {
let split_exec = StreamSplitExec::new(input, split_expr);
let output0 = run_and_get_output(&split_exec, 0).await.unwrap();
let expected = vec!["++", "||", "++", "++"];
let expected = vec!["+---------+", "| int_col |", "+---------+", "+---------+"];
assert_batches_sorted_eq!(&expected, &output0);
let output1 = run_and_get_output(&split_exec, 1).await.unwrap();

View File

@ -22,6 +22,7 @@
| | IOxReadFilterNode: table_name=h2o, chunks=1 predicate=Predicate |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=h2o, chunks=1 predicate=Predicate |
| | |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN select time, state, city, min_temp, max_temp, area from h2o;
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------+
@ -43,6 +44,7 @@
| | IOxReadFilterNode: table_name=h2o, chunks=1 predicate=Predicate |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=h2o, chunks=1 predicate=Predicate |
| | |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN select state as name from h2o UNION ALL select city as name from h2o;
+---------------+-----------------------------------------------------------------------------------+
@ -84,4 +86,5 @@
| | IOxReadFilterNode: table_name=h2o, chunks=1 predicate=Predicate |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=h2o, chunks=1 predicate=Predicate |
| | |
+---------------+-----------------------------------------------------------------------------------+

View File

@ -10,4 +10,5 @@
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | ProjectionExec: expr=[3 as COUNT(Uint8(1))] |
| | EmptyExec: produce_one_row=true |
| | |
+---------------+-------------------------------------------------------------+

View File

@ -8,6 +8,7 @@
| physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate |
| | |
+---------------+---------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where count > 200;
+---------------+-------------------------------------------------------------------------------------------------------------+
@ -21,6 +22,7 @@
| | FilterExec: CAST(count@0 AS Int64) > 200 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#count > Int64(200)] |
| | |
+---------------+-------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where count > 200.0;
+---------------+---------------------------------------------------------------------------------------------------------------+
@ -34,6 +36,7 @@
| | FilterExec: CAST(count@0 AS Float64) > 200 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#count > Float64(200)] |
| | |
+---------------+---------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where system > 4.0;
+---------------+--------------------------------------------------------------------------------------------------------------+
@ -47,6 +50,7 @@
| | FilterExec: system@1 > 4 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#system > Float64(4)] |
| | |
+---------------+--------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where count > 200 and town != 'tewsbury';
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------+
@ -60,6 +64,7 @@
| | FilterExec: CAST(count@0 AS Int64) > 200 AND CAST(town@3 AS Utf8) != tewsbury |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#count > Int64(200), #town != Utf8("tewsbury")] |
| | |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where count > 200 and town != 'tewsbury' and (system =5 or town = 'lawrence');
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@ -73,6 +78,7 @@
| | FilterExec: CAST(count@0 AS Int64) > 200 AND CAST(town@3 AS Utf8) != tewsbury AND system@1 = CAST(5 AS Float64) OR CAST(town@3 AS Utf8) = lawrence |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#count > Int64(200), #town != Utf8("tewsbury")] |
| | |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where count > 200 and town != 'tewsbury' and (system =5 or town = 'lawrence') and count < 40000;
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@ -86,6 +92,7 @@
| | FilterExec: CAST(count@0 AS Int64) > 200 AND CAST(town@3 AS Utf8) != tewsbury AND system@1 = CAST(5 AS Float64) OR CAST(town@3 AS Utf8) = lawrence AND CAST(count@0 AS Int64) < 40000 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#count > Int64(200), #town != Utf8("tewsbury"), #count < Int64(40000)] |
| | |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where count > 200 and count < 40000;
+---------------+-------------------------------------------------------------------------------------------------------------------------------------+
@ -99,6 +106,7 @@
| | FilterExec: CAST(count@0 AS Int64) > 200 AND CAST(count@0 AS Int64) < 40000 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#count > Int64(200), #count < Int64(40000)] |
| | |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where system > 4.0 and system < 7.0;
+---------------+-------------------------------------------------------------------------------------------------------------------------------------+
@ -112,6 +120,7 @@
| | FilterExec: system@1 > 4 AND system@1 < 7 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#system > Float64(4), #system < Float64(7)] |
| | |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where system > 5.0 and system < 7.0;
+---------------+-------------------------------------------------------------------------------------------------------------------------------------+
@ -125,6 +134,7 @@
| | FilterExec: system@1 > 5 AND system@1 < 7 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#system > Float64(5), #system < Float64(7)] |
| | |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where system > 5.0 and town != 'tewsbury' and 7.0 > system;
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@ -138,6 +148,7 @@
| | FilterExec: system@1 > 5 AND CAST(town@3 AS Utf8) != tewsbury AND 7 > system@1 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#system > Float64(5), #town != Utf8("tewsbury"), Float64(7) > #system] |
| | |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where system > 5.0 and 'tewsbury' != town and system < 7.0 and (count = 632 or town = 'reading');
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@ -151,6 +162,7 @@
| | FilterExec: system@1 > 5 AND tewsbury != CAST(town@3 AS Utf8) AND system@1 < 7 AND CAST(count@0 AS Int64) = 632 OR CAST(town@3 AS Utf8) = reading |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate exprs: [#system > Float64(5), Utf8("tewsbury") != #town, #system < Float64(7)] |
| | |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-- SQL: EXPLAIN SELECT * from restaurant where 5.0 < system and town != 'tewsbury' and system < 7.0 and (count = 632 or town = 'reading') and time > to_timestamp('1970-01-01T00:00:00.000000130+00:00');
+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@ -164,4 +176,5 @@
| | FilterExec: 5 < system@1 AND CAST(town@3 AS Utf8) != tewsbury AND system@1 < 7 AND CAST(count@0 AS Int64) = 632 OR CAST(town@3 AS Utf8) = reading AND time@2 > 130 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=restaurant, chunks=0 predicate=Predicate exprs: [Float64(5) < #system, #town != Utf8("tewsbury"), #system < Float64(7), #time > TimestampNanosecond(130)] |
| | |
+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

View File

@ -10,6 +10,7 @@
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | ProjectionExec: expr=[3 as COUNT(Uint8(1))] |
| | EmptyExec: produce_one_row=true |
| | |
+---------------+-------------------------------------------------------------+
-- SQL: EXPLAIN SELECT count(*) from h2o where temp > 70.0 and temp < 72.0;
+---------------+---------------------------------------------------------------------------------------------------------------------------------+
@ -27,4 +28,5 @@
| | FilterExec: temp@0 > 70 AND temp@0 < 72 |
| | RepartitionExec: partitioning=RoundRobinBatch(4) |
| | IOxReadFilterNode: table_name=h2o, chunks=1 predicate=Predicate exprs: [#temp > Float64(70), #temp < Float64(72)] |
| | |
+---------------+---------------------------------------------------------------------------------------------------------------------------------+

View File

@ -1,6 +1,7 @@
//! This module implements the `database` CLI command
use chrono::{DateTime, Utc};
use comfy_table::{Cell, Table};
use influxdb_iox_client::{
connection::Connection,
flight,
@ -11,7 +12,6 @@ use influxdb_iox_client::{
},
write::{self, WriteError},
};
use prettytable::{format, Cell, Row, Table};
use std::{
convert::TryInto, fs::File, io::Read, num::NonZeroU64, path::PathBuf, str::FromStr,
time::Duration,
@ -272,12 +272,12 @@ pub async fn command(connection: Connection, config: Config) -> Result<()> {
};
let mut table = Table::new();
table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
table.set_titles(Row::new(vec![
table.load_preset("||--+-++| ++++++");
table.set_header(vec![
Cell::new("Deleted at"),
Cell::new("Generation ID"),
Cell::new("Name"),
]));
]);
for database in databases {
let deleted_at = database
@ -287,11 +287,11 @@ pub async fn command(connection: Connection, config: Config) -> Result<()> {
dt.ok().map(|d| d.to_string())
})
.unwrap_or_else(String::new);
table.add_row(Row::new(vec![
table.add_row(vec![
Cell::new(&deleted_at),
Cell::new(&database.generation_id.to_string()),
Cell::new(&database.db_name),
]));
]);
}
print!("{}", table);

View File

@ -2,7 +2,7 @@ use influxdb_iox_client::{connection::Connection, management};
use structopt::StructOpt;
use thiserror::Error;
use prettytable::{format, Cell, Row, Table};
use comfy_table::{Cell, Table};
#[allow(clippy::enum_variant_names)]
#[derive(Debug, Error)]
@ -51,17 +51,14 @@ pub async fn command(connection: Connection, config: Config) -> Result<()> {
println!("no remotes configured");
} else {
let mut table = Table::new();
table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
table.set_titles(Row::new(vec![
Cell::new("ID"),
Cell::new("Connection string"),
]));
table.load_preset("||--+-++| ++++++");
table.set_header(vec![Cell::new("ID"), Cell::new("Connection string")]);
for i in remotes {
table.add_row(Row::new(vec![
table.add_row(vec![
Cell::new(&format!("{}", i.id)),
Cell::new(&i.connection_string),
]));
]);
}
print!("{}", table);
}

View File

@ -1440,8 +1440,7 @@ mod tests {
| bottom_degrees | location | state | surface_degrees | time |
+----------------+--------------+-------+-----------------+----------------------+
| 50.4 | santa_monica | CA | 65.2 | 2021-04-01T14:10:24Z |
+----------------+--------------+-------+-----------------+----------------------+
"#;
+----------------+--------------+-------+-----------------+----------------------+"#;
check_response("query", response, StatusCode::OK, Some(expected)).await;
@ -1651,7 +1650,12 @@ mod tests {
assert_eq!(status, expected_status);
if let Some(expected_body) = expected_body {
assert!(body.contains(expected_body));
assert!(
body.contains(expected_body),
"Could not find expected in body.\n\nExpected:\n{}\n\nBody:\n{}",
expected_body,
body
);
}
} else {
panic!("Unexpected error response: {:?}", response);

View File

@ -64,7 +64,12 @@ async fn test_operations() {
let query_results = client.perform_query(&db_name2, sql_query).await.unwrap();
let batches = collect_query(query_results).await;
let expected_read_data = vec!["++", "||", "++", "++"];
let expected_read_data = vec![
"+--------+-------------+",
"| status | description |",
"+--------+-------------+",
"+--------+-------------+",
];
assert_batches_eq!(expected_read_data, &batches);
}