@@ -1095,7 +1095,7 @@ def test_add_required_column(catalog: Catalog) -> None:
10951095
10961096@pytest .mark .integration
10971097@pytest .mark .parametrize (
1098- "iceberg_type, default_value , write_default" ,
1098+ "iceberg_type, initial_default , write_default" ,
10991099 [
11001100 (BooleanType (), True , False ),
11011101 (IntegerType (), 123 , 456 ),
@@ -1119,25 +1119,33 @@ def test_add_required_column(catalog: Catalog) -> None:
11191119 ],
11201120)
11211121def test_initial_default_all_columns (
1122- catalog : Catalog , iceberg_type : PrimitiveType , default_value : Any , write_default : Any
1122+ catalog : Catalog , iceberg_type : PrimitiveType , initial_default : Any , write_default : Any
11231123) -> None :
11241124 # Round trips all the types through the rest catalog to check the serialization
11251125 table = _create_table_with_schema (catalog , Schema (), properties = {TableProperties .FORMAT_VERSION : 3 })
11261126
11271127 tx = table .update_schema ()
1128- tx .add_column (path = "data" , field_type = iceberg_type , required = True , default_value = default_value )
1128+ tx .add_column (path = "data" , field_type = iceberg_type , required = True , default_value = initial_default )
1129+ tx .add_column (path = "nested" , field_type = StructType (), required = False )
11291130 tx .commit ()
11301131
1131- field = table .schema ().find_field (1 )
1132- assert field .initial_default == default_value
1133- assert field .write_default == default_value
1132+ tx = table .update_schema ()
1133+ tx .add_column (path = ("nested" , "data" ), field_type = iceberg_type , required = True , default_value = initial_default )
1134+ tx .commit ()
1135+
1136+ for field_id in [1 , 3 ]:
1137+ field = table .schema ().find_field (field_id )
1138+ assert field .initial_default == initial_default
1139+ assert field .write_default == initial_default
11341140
11351141 with table .update_schema () as tx :
11361142 tx .set_default_value ("data" , write_default )
1143+ tx .set_default_value (("nested" , "data" ), write_default )
11371144
1138- field = table .schema ().find_field (1 )
1139- assert field .initial_default == default_value
1140- assert field .write_default == write_default
1145+ for field_id in [1 , 3 ]:
1146+ field = table .schema ().find_field (field_id )
1147+ assert field .initial_default == initial_default
1148+ assert field .write_default == write_default
11411149
11421150
11431151@pytest .mark .integration
0 commit comments