|
33 | 33 |
|
34 | 34 | from pyiceberg.catalog import Catalog, Properties, Table, load_catalog |
35 | 35 | from pyiceberg.catalog.sql import SqlCatalog |
36 | | -from pyiceberg.exceptions import NamespaceAlreadyExistsError, NoSuchTableError |
| 36 | +from pyiceberg.exceptions import NamespaceAlreadyExistsError, NoSuchTableError, ServerError |
37 | 37 | from pyiceberg.schema import Schema |
38 | 38 | from pyiceberg.table import _dataframe_to_data_files |
39 | 39 | from pyiceberg.types import ( |
@@ -676,3 +676,37 @@ def test_write_and_evolve(session_catalog: Catalog, format_version: int) -> None |
676 | 676 | with txn.update_snapshot().fast_append() as snapshot_update: |
677 | 677 | for data_file in _dataframe_to_data_files(table=tbl, df=pa_table_with_column, file_schema=txn.schema()): |
678 | 678 | snapshot_update.append_data_file(data_file) |
| 679 | + |
| 680 | + |
| 681 | +@pytest.mark.integration |
| 682 | +@pytest.mark.parametrize("format_version", [1, 2]) |
| 683 | +def test_table_properties_int_value( |
| 684 | + session_catalog: Catalog, |
| 685 | + arrow_table_with_null: pa.Table, |
| 686 | + format_version: str, |
| 687 | +) -> None: |
| 688 | + # table properties can be set to int, but still serialized to string |
| 689 | + property_with_int = {"property_name": 42} |
| 690 | + identifier = "default.test_table_properties_int_value" |
| 691 | + |
| 692 | + tbl = _create_table( |
| 693 | + session_catalog, identifier, {"format-version": format_version, **property_with_int}, [arrow_table_with_null] |
| 694 | + ) |
| 695 | + assert isinstance(tbl.properties["property_name"], str) |
| 696 | + |
| 697 | + |
| 698 | +@pytest.mark.integration |
| 699 | +@pytest.mark.parametrize("format_version", [1, 2]) |
| 700 | +def test_table_properties_raise_for_none_value( |
| 701 | + session_catalog: Catalog, |
| 702 | + arrow_table_with_null: pa.Table, |
| 703 | + format_version: str, |
| 704 | +) -> None: |
| 705 | + property_with_none = {"property_name": None} |
| 706 | + identifier = "default.test_table_properties_raise_for_none_value" |
| 707 | + |
| 708 | + with pytest.raises(ServerError) as exc_info: |
| 709 | + _ = _create_table( |
| 710 | + session_catalog, identifier, {"format-version": format_version, **property_with_none}, [arrow_table_with_null] |
| 711 | + ) |
| 712 | + assert "NullPointerException: null value in entry: property_name=null" in str(exc_info.value) |
0 commit comments