Skip to content

Commit

Permalink
cli: avoid special lines at the end of CSV/TSV output
Browse files Browse the repository at this point in the history
Prior to this patch, the csv/tsv formatters would end a table with a
row count. This is not great for interoperability with external tools
which may expect to be able to redirect the table output to a file and
open that directly in a csv/tsv reader, where the final row count
would be incorrectly interpreted as an extra row.

This patch changes the behavior by omitting the row count altogether
for csv/tsv output.

Release note (cli change): when printing tabular results as CSV or
TSV, no final row count is emitted. This is intended to increase
interoperability with external tools.
  • Loading branch information
knz committed Feb 7, 2018
1 parent 0814753 commit 13d9e88
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 100 deletions.
1 change: 0 additions & 1 deletion build/verify-archive.sh
Expand Up @@ -24,6 +24,5 @@ EOF
diff -u - <(cockroach sql --insecure -e 'SELECT * FROM bank.accounts') <<EOF
id balance
1 1000.50
# 1 row
EOF
cockroach quit --insecure
9 changes: 0 additions & 9 deletions pkg/acceptance/decommission_test.go
Expand Up @@ -156,7 +156,6 @@ func testDecommissionInner(
exp := [][]string{
decommissionHeader,
{strconv.Itoa(int(idMap[0])), "true", "0", "true", "true"},
{"# 1 row"},
decommissionFooterLive,
}
log.Infof(ctx, o)
Expand All @@ -180,7 +179,6 @@ func testDecommissionInner(
{"2"},
{"3"},
{"4"},
{"# 4 rows"},
}
if err := matchCSV(o, exp); err != nil {
t.Fatal(err)
Expand All @@ -198,7 +196,6 @@ func testDecommissionInner(
{`2`, `.*`, `.*`, `.*`, `.*`, `.*`},
{`3`, `.*`, `.*`, `.*`, `.*`, `.*`},
{`4`, `.*`, `.*`, `.*`, `.*`, `.*`},
{"# 4 rows"},
}
if err := matchCSV(o, exp); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -231,7 +228,6 @@ func testDecommissionInner(
exp := [][]string{
decommissionHeader,
{strconv.Itoa(int(target)), "true", "0", "true", "true"},
{"# 1 row"},
decommissionFooter,
}
if err := matchCSV(o, exp); err != nil {
Expand Down Expand Up @@ -289,7 +285,6 @@ func testDecommissionInner(
exp := [][]string{
decommissionHeader,
{strconv.Itoa(int(target)), "true", "0", "true", "true"},
{"# 1 row"},
decommissionFooter,
}
if err := matchCSV(o, exp); err != nil {
Expand Down Expand Up @@ -337,7 +332,6 @@ func testDecommissionInner(
exp := [][]string{
decommissionHeader,
{strconv.Itoa(int(target)), "true", "0", "true", "true"},
{"# 1 row"},
decommissionFooter,
}
if err := matchCSV(o, exp); err != nil {
Expand Down Expand Up @@ -379,7 +373,6 @@ func testDecommissionInner(
exp := [][]string{
decommissionHeader,
{strconv.Itoa(int(target)), `true|false`, `\d+`, `true`, `true|false`},
{"# 1 row"},
decommissionFooterLive,
}
if err := matchCSV(o, exp); err != nil {
Expand All @@ -402,7 +395,6 @@ func testDecommissionInner(
{"2"},
{"3"},
{"4"},
{"# 3 rows"},
}

if err := matchCSV(o, exp); err != nil {
Expand All @@ -424,7 +416,6 @@ func testDecommissionInner(
{`2`, `.*`, `.*`, `.*`, `.*`, `.*`},
{`3`, `.*`, `.*`, `.*`, `.*`, `.*`},
{`4`, `.*`, `.*`, `.*`, `.*`, `.*`},
{"# 3 rows"},
}
if err := matchCSV(o, exp); err != nil {
time.Sleep(time.Second)
Expand Down

0 comments on commit 13d9e88

Please sign in to comment.