diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc index 0c66f6e8f5461..bdcf89c37f506 100644 --- a/cpp/src/arrow/pretty_print.cc +++ b/cpp/src/arrow/pretty_print.cc @@ -496,8 +496,7 @@ Status PrettyPrint(const ChunkedArray& chunked_arr, const PrettyPrintOptions& op } else { PrettyPrintOptions chunk_options = options; chunk_options.indent += options.indent_size; - ArrayPrinter printer(chunk_options, sink); - RETURN_NOT_OK(printer.Print(*chunked_arr.chunk(i))); + RETURN_NOT_OK(PrettyPrint(*chunked_arr.chunk(i), chunk_options, sink)); } } if (!options.skip_new_lines) { diff --git a/python/pyarrow/tests/test_cuda.py b/python/pyarrow/tests/test_cuda.py index 43cd16a3cf666..cb068e02c706c 100644 --- a/python/pyarrow/tests/test_cuda.py +++ b/python/pyarrow/tests/test_cuda.py @@ -792,3 +792,57 @@ def test_IPC(size): p.start() p.join() assert p.exitcode == 0 + + +def test_print_array(): + batch = make_recordbatch(10) + cbuf = cuda.serialize_record_batch(batch, global_context) + cbatch = cuda.read_record_batch(cbuf, batch.schema) + arr = batch["f0"] + carr = cbatch["f0"] + assert str(carr) == str(arr) + + batch = make_recordbatch(100) + cbuf = cuda.serialize_record_batch(batch, global_context) + cbatch = cuda.read_record_batch(cbuf, batch.schema) + arr = batch["f0"] + carr = cbatch["f0"] + assert str(carr) == str(arr) + + +def make_chunked_array(n_elements_per_chunk, n_chunks): + arrs = [] + carrs = [] + for _ in range(n_chunks): + batch = make_recordbatch(n_elements_per_chunk) + cbuf = cuda.serialize_record_batch(batch, global_context) + cbatch = cuda.read_record_batch(cbuf, batch.schema) + arrs.append(batch["f0"]) + carrs.append(cbatch["f0"]) + + return pa.chunked_array(arrs), pa.chunked_array(carrs) + + +def test_print_chunked_array(): + arr, carr = make_chunked_array(10, 3) + assert str(carr) == str(arr) + + arr, carr = make_chunked_array(100, 20) + assert str(carr) == str(arr) + + +def test_print_record_batch(): + batch = make_recordbatch(10) + cbuf = cuda.serialize_record_batch(batch, global_context) + cbatch = cuda.read_record_batch(cbuf, batch.schema) + assert str(cbatch) == str(batch) + + batch = make_recordbatch(100) + cbuf = cuda.serialize_record_batch(batch, global_context) + cbatch = cuda.read_record_batch(cbuf, batch.schema) + assert str(cbatch) == str(batch) + + +def test_print_table(): + _, table, _, ctable = make_table_cuda() + assert str(ctable) == str(table)