| 2660 | |
| 2661 | |
| 2662 | def test_table_factory_function_args(): |
| 2663 | # from_pydict not accepting names: |
| 2664 | with pytest.raises(ValueError): |
| 2665 | pa.table({'a': [1, 2, 3]}, names=['a']) |
| 2666 | |
| 2667 | # backwards compatibility for schema as first positional argument |
| 2668 | schema = pa.schema([('a', pa.int32())]) |
| 2669 | table = pa.table({'a': pa.array([1, 2, 3], type=pa.int64())}, schema) |
| 2670 | assert table.column('a').type == pa.int32() |
| 2671 | |
| 2672 | # from_arrays: accept both names and schema as positional first argument |
| 2673 | data = [pa.array([1, 2, 3], type='int64')] |
| 2674 | names = ['a'] |
| 2675 | table = pa.table(data, names) |
| 2676 | assert table.column_names == names |
| 2677 | schema = pa.schema([('a', pa.int64())]) |
| 2678 | table = pa.table(data, schema) |
| 2679 | assert table.column_names == names |
| 2680 | |
| 2681 | |
| 2682 | @pytest.mark.pandas |