| 2705 | |
| 2706 | |
| 2707 | def test_table_repr_to_string(): |
| 2708 | # Schema passed explicitly |
| 2709 | schema = pa.schema([pa.field('c0', pa.int16(), |
| 2710 | metadata={'key': 'value'}), |
| 2711 | pa.field('c1', pa.int32())], |
| 2712 | metadata={b'foo': b'bar'}) |
| 2713 | |
| 2714 | tab = pa.table([pa.array([1, 2, 3, 4], type='int16'), |
| 2715 | pa.array([10, 20, 30, 40], type='int32')], schema=schema) |
| 2716 | assert str(tab) == """pyarrow.Table |
| 2717 | c0: int16 |
| 2718 | c1: int32 |
| 2719 | ---- |
| 2720 | c0: [[1,2,3,4]] |
| 2721 | c1: [[10,20,30,40]]""" |
| 2722 | |
| 2723 | assert tab.to_string(show_metadata=True) == """\ |
| 2724 | pyarrow.Table |
| 2725 | c0: int16 |
| 2726 | -- field metadata -- |
| 2727 | key: 'value' |
| 2728 | c1: int32 |
| 2729 | -- schema metadata -- |
| 2730 | foo: 'bar'""" |
| 2731 | |
| 2732 | assert tab.to_string(preview_cols=5) == """\ |
| 2733 | pyarrow.Table |
| 2734 | c0: int16 |
| 2735 | c1: int32 |
| 2736 | ---- |
| 2737 | c0: [[1,2,3,4]] |
| 2738 | c1: [[10,20,30,40]]""" |
| 2739 | |
| 2740 | assert tab.to_string(preview_cols=1) == """\ |
| 2741 | pyarrow.Table |
| 2742 | c0: int16 |
| 2743 | c1: int32 |
| 2744 | ---- |
| 2745 | c0: [[1,2,3,4]] |
| 2746 | ...""" |
| 2747 | |
| 2748 | |
| 2749 | def test_table_repr_to_string_ellipsis(): |