| 2599 | |
| 2600 | |
| 2601 | def test_table_factory_function_args(): |
| 2602 | # from_pydict not accepting names: |
| 2603 | with pytest.raises(ValueError): |
| 2604 | pa.table({'a': [1, 2, 3]}, names=['a']) |
| 2605 | |
| 2606 | # backwards compatibility for schema as first positional argument |
| 2607 | schema = pa.schema([('a', pa.int32())]) |
| 2608 | table = pa.table({'a': pa.array([1, 2, 3], type=pa.int64())}, schema) |
| 2609 | assert table.column('a').type == pa.int32() |
| 2610 | |
| 2611 | # from_arrays: accept both names and schema as positional first argument |
| 2612 | data = [pa.array([1, 2, 3], type='int64')] |
| 2613 | names = ['a'] |
| 2614 | table = pa.table(data, names) |
| 2615 | assert table.column_names == names |
| 2616 | schema = pa.schema([('a', pa.int64())]) |
| 2617 | table = pa.table(data, schema) |
| 2618 | assert table.column_names == names |
| 2619 | |
| 2620 | |
| 2621 | @pytest.mark.pandas |