Skip to content
Closed
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
8 changes: 7 additions & 1 deletion cpp/src/arrow/pretty_print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,17 @@ class ArrayPrinter : public PrettyPrinter {
IndentAfterNewline();
(*sink_) << "...";
if (!is_last && options_.skip_new_lines) {
(*sink_) << ",";
(*sink_) << ", ";
}
i = array.length() - options_.window - 1;
} else if (array.IsNull(i)) {
IndentAfterNewline();
(*sink_) << options_.null_rep;
if (!is_last) {
(*sink_) << ",";
if (options_.skip_new_lines) {
(*sink_) << " ";
}
}
} else {
if (indent_non_null_values) {
Expand All @@ -159,6 +162,9 @@ class ArrayPrinter : public PrettyPrinter {
RETURN_NOT_OK(func(i));
if (!is_last) {
(*sink_) << ",";
if (options_.skip_new_lines) {
(*sink_) << " ";
}
}
}
Newline();
Expand Down
12 changes: 6 additions & 6 deletions cpp/src/arrow/pretty_print_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ TEST_F(TestPrettyPrint, PrimitiveTypeNoNewlines) {
options.skip_new_lines = true;
options.window = 4;

const char* expected = "[0,1,null,3,null]";
const char* expected = "[0, 1, null, 3, null]";
CheckPrimitive<Int32Type, int32_t>(options, is_valid, values, expected, false);

// With ellipsis
Expand All @@ -188,7 +188,7 @@ TEST_F(TestPrettyPrint, PrimitiveTypeNoNewlines) {
values.insert(values.end(), 20, 99);
values.insert(values.end(), {44, 43, 42});

expected = "[0,1,null,3,...,99,44,null,42]";
expected = "[0, 1, null, 3, ..., 99, 44, null, 42]";
CheckPrimitive<Int32Type, int32_t>(options, is_valid, values, expected, false);
}

Expand Down Expand Up @@ -661,12 +661,12 @@ TEST_F(TestPrettyPrint, BinaryNoNewlines) {
PrettyPrintOptions options{};
options.skip_new_lines = true;

const char* expected = "[666F6F,626172,null,62617A,,FF]";
const char* expected = "[666F6F, 626172, null, 62617A, , FF]";
CheckPrimitive<BinaryType, std::string>(options, is_valid, values, expected, false);

// With ellipsis
options.window = 2;
expected = "[666F6F,626172,...,,FF]";
expected = "[666F6F, 626172, ..., , FF]";
CheckPrimitive<BinaryType, std::string>(options, is_valid, values, expected, false);
}

Expand Down Expand Up @@ -737,11 +737,11 @@ TEST_F(TestPrettyPrint, ListTypeNoNewlines) {
options.skip_new_lines = true;
options.null_rep = "NA";
CheckArray(*empty_array, options, "[]", false);
CheckArray(*array, options, "[[NA],[],NA,[4,5,6,7,8],[2,3]]", false);
CheckArray(*array, options, "[[NA], [], NA, [4, 5, 6, 7, 8], [2, 3]]", false);

options.window = 2;
CheckArray(*empty_array, options, "[]", false);
CheckArray(*array, options, "[[NA],[],...,[4,5,...,7,8],[2,3]]", false);
CheckArray(*array, options, "[[NA], [], ..., [4, 5, ..., 7, 8], [2, 3]]", false);
}

TEST_F(TestPrettyPrint, MapType) {
Expand Down
15 changes: 8 additions & 7 deletions python/pyarrow/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,8 +1758,8 @@ def test_table_repr_to_string():
c0: int16
c1: int32
----
c0: [[1,2,3,4]]
c1: [[10,20,30,40]]"""
c0: [[1, 2, 3, 4]]
c1: [[10, 20, 30, 40]]"""

assert tab.to_string(show_metadata=True) == """\
pyarrow.Table
Expand All @@ -1775,15 +1775,15 @@ def test_table_repr_to_string():
c0: int16
c1: int32
----
c0: [[1,2,3,4]]
c1: [[10,20,30,40]]"""
c0: [[1, 2, 3, 4]]
c1: [[10, 20, 30, 40]]"""

assert tab.to_string(preview_cols=1) == """\
pyarrow.Table
c0: int16
c1: int32
----
c0: [[1,2,3,4]]
c0: [[1, 2, 3, 4]]
..."""


Expand All @@ -1801,8 +1801,9 @@ def test_table_repr_to_string_ellipsis():
c0: int16
c1: int32
----
c0: [[1,2,3,4,1,2,3,4,1,2,...,3,4,1,2,3,4,1,2,3,4]]
c1: [[10,20,30,40,10,20,30,40,10,20,...,30,40,10,20,30,40,10,20,30,40]]"""
c0: [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2, ..., 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]]
c1: [[10, 20, 30, 40, 10, 20, 30, 40, 10, 20, ..., 30, 40, 10, 20, 30, 40,\
10, 20, 30, 40]]"""


def test_table_function_unicode_schema():
Expand Down