28
28
import pytest
29
29
import pytz
30
30
from pyarrow .fs import S3FileSystem
31
+ from pydantic_core import ValidationError
31
32
from pyspark .sql import SparkSession
32
33
from pytest_mock .plugin import MockerFixture
33
34
@@ -403,7 +404,7 @@ def test_data_files(spark: SparkSession, session_catalog: Catalog, arrow_table_w
403
404
404
405
405
406
@pytest .mark .integration
406
- @pytest .mark .parametrize ("format_version" , ["1" , "2" ])
407
+ @pytest .mark .parametrize ("format_version" , [1 , 2 ])
407
408
@pytest .mark .parametrize (
408
409
"properties, expected_compression_name" ,
409
410
[
@@ -419,7 +420,7 @@ def test_write_parquet_compression_properties(
419
420
spark : SparkSession ,
420
421
session_catalog : Catalog ,
421
422
arrow_table_with_null : pa .Table ,
422
- format_version : str ,
423
+ format_version : int ,
423
424
properties : Dict [str , Any ],
424
425
expected_compression_name : str ,
425
426
) -> None :
@@ -654,3 +655,37 @@ def test_write_and_evolve(session_catalog: Catalog, format_version: int) -> None
654
655
with txn .update_snapshot ().fast_append () as snapshot_update :
655
656
for data_file in _dataframe_to_data_files (table_metadata = txn .table_metadata , df = pa_table_with_column , io = tbl .io ):
656
657
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