@@ -280,6 +280,43 @@ def test_query_filter_v1_v2_append_null(
280280 assert df .where (f"{ col } is null" ).count () == 2 , f"Expected 2 null rows for { col } "
281281
282282
283+ @pytest .mark .integration
284+ @pytest .mark .parametrize (
285+ "part_col" , ["int" , "bool" , "string" , "string_long" , "long" , "float" , "double" , "date" , "timestamp" , "timestamptz" , "binary" ]
286+ )
287+ @pytest .mark .parametrize ("format_version" , [1 , 2 ])
288+ def test_object_storage_excludes_partition (
289+ session_catalog : Catalog , spark : SparkSession , arrow_table_with_null : pa .Table , part_col : str , format_version : int
290+ ) -> None :
291+ nested_field = TABLE_SCHEMA .find_field (part_col )
292+ partition_spec = PartitionSpec (
293+ PartitionField (source_id = nested_field .field_id , field_id = 1001 , transform = IdentityTransform (), name = part_col )
294+ )
295+
296+ tbl = _create_table (
297+ session_catalog = session_catalog ,
298+ identifier = f"default.arrow_table_v{ format_version } _with_null_partitioned_on_col_{ part_col } " ,
299+ properties = {"format-version" : str (format_version ), "write.object-storage.enabled" : True },
300+ data = [arrow_table_with_null ],
301+ partition_spec = partition_spec ,
302+ )
303+
304+ original_paths = tbl .inspect .data_files ().to_pydict ()["file_path" ]
305+ assert len (original_paths ) == 3
306+
307+ # Update props to exclude partitioned paths and append data
308+ with tbl .transaction () as tx :
309+ tx .set_properties ({"write.object-storage.partitioned-paths" : False })
310+ tbl .append (arrow_table_with_null )
311+
312+ added_paths = set (tbl .inspect .data_files ().to_pydict ()["file_path" ]) - set (original_paths )
313+ assert len (added_paths ) == 3
314+
315+ # All paths before the props update should contain the partition, while all paths after should not
316+ assert all (f"{ part_col } =" in path for path in original_paths )
317+ assert all (f"{ part_col } =" not in path for path in added_paths )
318+
319+
283320@pytest .mark .integration
284321@pytest .mark .parametrize (
285322 "spec" ,
0 commit comments