| 3498 | ] |
| 3499 | ) |
| 3500 | def test_table_cast_invalid(cls): |
| 3501 | # Casting a nullable field to non-nullable should be invalid! |
| 3502 | table = cls.from_pydict({'a': [None, 1], 'b': [None, True]}) |
| 3503 | new_schema = pa.schema([pa.field("a", "int64", nullable=True), |
| 3504 | pa.field("b", "bool", nullable=False)]) |
| 3505 | with pytest.raises(ValueError): |
| 3506 | table.cast(new_schema) |
| 3507 | |
| 3508 | table = cls.from_pydict({'a': [None, 1], 'b': [False, True]}) |
| 3509 | assert table.cast(new_schema).schema == new_schema |
| 3510 | |
| 3511 | |
| 3512 | @pytest.mark.parametrize( |