5959 Table ,
6060 UpdateSchema ,
6161 _apply_table_update ,
62- _check_schema ,
62+ _check_schema_compatible ,
6363 _generate_snapshot_id ,
6464 _match_deletes_to_data_file ,
6565 _TableMetadataUpdateContext ,
@@ -1004,7 +1004,7 @@ def test_schema_mismatch_type(table_schema_simple: Schema) -> None:
10041004"""
10051005
10061006 with pytest .raises (ValueError , match = expected ):
1007- _check_schema (table_schema_simple , other_schema )
1007+ _check_schema_compatible (table_schema_simple , other_schema )
10081008
10091009
10101010def test_schema_mismatch_nullability (table_schema_simple : Schema ) -> None :
@@ -1025,7 +1025,7 @@ def test_schema_mismatch_nullability(table_schema_simple: Schema) -> None:
10251025"""
10261026
10271027 with pytest .raises (ValueError , match = expected ):
1028- _check_schema (table_schema_simple , other_schema )
1028+ _check_schema_compatible (table_schema_simple , other_schema )
10291029
10301030
10311031def test_schema_mismatch_missing_field (table_schema_simple : Schema ) -> None :
@@ -1045,7 +1045,7 @@ def test_schema_mismatch_missing_field(table_schema_simple: Schema) -> None:
10451045"""
10461046
10471047 with pytest .raises (ValueError , match = expected ):
1048- _check_schema (table_schema_simple , other_schema )
1048+ _check_schema_compatible (table_schema_simple , other_schema )
10491049
10501050
10511051def test_schema_mismatch_additional_field (table_schema_simple : Schema ) -> None :
@@ -1059,4 +1059,18 @@ def test_schema_mismatch_additional_field(table_schema_simple: Schema) -> None:
10591059 expected = r"PyArrow table contains more columns: new_field. Update the schema first \(hint, use union_by_name\)."
10601060
10611061 with pytest .raises (ValueError , match = expected ):
1062- _check_schema (table_schema_simple , other_schema )
1062+ _check_schema_compatible (table_schema_simple , other_schema )
1063+
1064+
1065+ def test_schema_downcast (table_schema_simple : Schema ) -> None :
1066+ # large_string type is compatible with string type
1067+ other_schema = pa .schema ((
1068+ pa .field ("foo" , pa .large_string (), nullable = True ),
1069+ pa .field ("bar" , pa .int32 (), nullable = False ),
1070+ pa .field ("baz" , pa .bool_ (), nullable = True ),
1071+ ))
1072+
1073+ try :
1074+ _check_schema_compatible (table_schema_simple , other_schema )
1075+ except Exception :
1076+ pytest .fail ("Unexpected Exception raised when calling `_check_schema`" )
0 commit comments