|
21 | 21 |
|
22 | 22 | import pyarrow as pa |
23 | 23 | import pytest |
| 24 | +from pydantic_core import ValidationError |
24 | 25 | from pytest_lazyfixture import lazy_fixture |
25 | 26 | from sqlalchemy.exc import ArgumentError, IntegrityError |
26 | 27 |
|
@@ -639,7 +640,7 @@ def test_create_namespace_with_null_properties(catalog: SqlCatalog, database_nam |
639 | 640 | catalog.create_namespace(namespace=database_name, properties={None: "value"}) # type: ignore |
640 | 641 |
|
641 | 642 | with pytest.raises(IntegrityError): |
642 | | - catalog.create_namespace(namespace=database_name, properties={"key": None}) # type: ignore |
| 643 | + catalog.create_namespace(namespace=database_name, properties={"key": None}) |
643 | 644 |
|
644 | 645 |
|
645 | 646 | @pytest.mark.parametrize( |
@@ -851,3 +852,39 @@ def test_concurrent_commit_table(catalog: SqlCatalog, table_schema_simple: Schem |
851 | 852 | # This one should fail since it already has been updated |
852 | 853 | with table_b.update_schema() as update: |
853 | 854 | update.add_column(path="c", field_type=IntegerType()) |
| 855 | + |
| 856 | + |
| 857 | +@pytest.mark.parametrize( |
| 858 | + 'catalog', |
| 859 | + [ |
| 860 | + lazy_fixture('catalog_memory'), |
| 861 | + lazy_fixture('catalog_sqlite'), |
| 862 | + lazy_fixture('catalog_sqlite_without_rowcount'), |
| 863 | + ], |
| 864 | +) |
| 865 | +def test_table_properties_int_value(catalog: SqlCatalog, table_schema_simple: Schema, random_identifier: Identifier) -> None: |
| 866 | + # table properties can be set to int, but still serialized to string |
| 867 | + database_name, _table_name = random_identifier |
| 868 | + catalog.create_namespace(database_name) |
| 869 | + property_with_int = {"property_name": 42} |
| 870 | + table = catalog.create_table(random_identifier, table_schema_simple, properties=property_with_int) |
| 871 | + assert isinstance(table.properties["property_name"], str) |
| 872 | + |
| 873 | + |
| 874 | +@pytest.mark.parametrize( |
| 875 | + 'catalog', |
| 876 | + [ |
| 877 | + lazy_fixture('catalog_memory'), |
| 878 | + lazy_fixture('catalog_sqlite'), |
| 879 | + lazy_fixture('catalog_sqlite_without_rowcount'), |
| 880 | + ], |
| 881 | +) |
| 882 | +def test_table_properties_raise_for_none_value( |
| 883 | + catalog: SqlCatalog, table_schema_simple: Schema, random_identifier: Identifier |
| 884 | +) -> None: |
| 885 | + database_name, _table_name = random_identifier |
| 886 | + catalog.create_namespace(database_name) |
| 887 | + property_with_none = {"property_name": None} |
| 888 | + with pytest.raises(ValidationError) as exc_info: |
| 889 | + _ = catalog.create_table(random_identifier, table_schema_simple, properties=property_with_none) |
| 890 | + assert "None type is not a supported value in properties" in str(exc_info.value) |
0 commit comments