| 2644 | |
| 2645 | |
| 2646 | def test_table_repr_to_string(): |
| 2647 | # Schema passed explicitly |
| 2648 | schema = pa.schema([pa.field('c0', pa.int16(), |
| 2649 | metadata={'key': 'value'}), |
| 2650 | pa.field('c1', pa.int32())], |
| 2651 | metadata={b'foo': b'bar'}) |
| 2652 | |
| 2653 | tab = pa.table([pa.array([1, 2, 3, 4], type='int16'), |
| 2654 | pa.array([10, 20, 30, 40], type='int32')], schema=schema) |
| 2655 | assert str(tab) == """pyarrow.Table |
| 2656 | c0: int16 |
| 2657 | c1: int32 |
| 2658 | ---- |
| 2659 | c0: [[1,2,3,4]] |
| 2660 | c1: [[10,20,30,40]]""" |
| 2661 | |
| 2662 | assert tab.to_string(show_metadata=True) == """\ |
| 2663 | pyarrow.Table |
| 2664 | c0: int16 |
| 2665 | -- field metadata -- |
| 2666 | key: 'value' |
| 2667 | c1: int32 |
| 2668 | -- schema metadata -- |
| 2669 | foo: 'bar'""" |
| 2670 | |
| 2671 | assert tab.to_string(preview_cols=5) == """\ |
| 2672 | pyarrow.Table |
| 2673 | c0: int16 |
| 2674 | c1: int32 |
| 2675 | ---- |
| 2676 | c0: [[1,2,3,4]] |
| 2677 | c1: [[10,20,30,40]]""" |
| 2678 | |
| 2679 | assert tab.to_string(preview_cols=1) == """\ |
| 2680 | pyarrow.Table |
| 2681 | c0: int16 |
| 2682 | c1: int32 |
| 2683 | ---- |
| 2684 | c0: [[1,2,3,4]] |
| 2685 | ...""" |
| 2686 | |
| 2687 | |
| 2688 | def test_table_repr_to_string_ellipsis(): |