2828import pytest
2929import pytz
3030from pyarrow .fs import S3FileSystem
31+ from pydantic_core import ValidationError
3132from pyspark .sql import SparkSession
3233from pytest_mock .plugin import MockerFixture
3334
@@ -403,7 +404,7 @@ def test_data_files(spark: SparkSession, session_catalog: Catalog, arrow_table_w
403404
404405
405406@pytest .mark .integration
406- @pytest .mark .parametrize ("format_version" , ["1" , "2" ])
407+ @pytest .mark .parametrize ("format_version" , [1 , 2 ])
407408@pytest .mark .parametrize (
408409 "properties, expected_compression_name" ,
409410 [
@@ -419,7 +420,7 @@ def test_write_parquet_compression_properties(
419420 spark : SparkSession ,
420421 session_catalog : Catalog ,
421422 arrow_table_with_null : pa .Table ,
422- format_version : str ,
423+ format_version : int ,
423424 properties : Dict [str , Any ],
424425 expected_compression_name : str ,
425426) -> None :
@@ -654,3 +655,37 @@ def test_write_and_evolve(session_catalog: Catalog, format_version: int) -> None
654655 with txn .update_snapshot ().fast_append () as snapshot_update :
655656 for data_file in _dataframe_to_data_files (table_metadata = txn .table_metadata , df = pa_table_with_column , io = tbl .io ):
656657 snapshot_update .append_data_file (data_file )
658+
659+
660+ @pytest .mark .integration
661+ @pytest .mark .parametrize ("format_version" , [1 , 2 ])
662+ def test_table_properties_int_value (
663+ session_catalog : Catalog ,
664+ arrow_table_with_null : pa .Table ,
665+ format_version : int ,
666+ ) -> None :
667+ # table properties can be set to int, but still serialized to string
668+ property_with_int = {"property_name" : 42 }
669+ identifier = "default.test_table_properties_int_value"
670+
671+ tbl = _create_table (
672+ session_catalog , identifier , {"format-version" : format_version , ** property_with_int }, [arrow_table_with_null ]
673+ )
674+ assert isinstance (tbl .properties ["property_name" ], str )
675+
676+
677+ @pytest .mark .integration
678+ @pytest .mark .parametrize ("format_version" , [1 , 2 ])
679+ def test_table_properties_raise_for_none_value (
680+ session_catalog : Catalog ,
681+ arrow_table_with_null : pa .Table ,
682+ format_version : int ,
683+ ) -> None :
684+ property_with_none = {"property_name" : None }
685+ identifier = "default.test_table_properties_raise_for_none_value"
686+
687+ with pytest .raises (ValidationError ) as exc_info :
688+ _ = _create_table (
689+ session_catalog , identifier , {"format-version" : format_version , ** property_with_none }, [arrow_table_with_null ]
690+ )
691+ assert "None type is not a supported value in properties: property_name" in str (exc_info .value )
0 commit comments