@@ -2416,6 +2416,36 @@ def test_partition_for_deep_nested_field() -> None:
24162416 assert partition_values == {"data-1" , "data-2" }
24172417
24182418
2419+ def test_inspect_partition_for_nested_field (catalog : InMemoryCatalog ) -> None :
2420+ schema = Schema (
2421+ NestedField (id = 1 , name = "foo" , field_type = StringType (), required = True ),
2422+ NestedField (
2423+ id = 2 ,
2424+ name = "bar" ,
2425+ field_type = StructType (
2426+ NestedField (id = 3 , name = "baz" , field_type = StringType (), required = False ),
2427+ NestedField (id = 4 , name = "qux" , field_type = IntegerType (), required = False ),
2428+ ),
2429+ required = True ,
2430+ ),
2431+ )
2432+ spec = PartitionSpec (PartitionField (source_id = 3 , field_id = 1000 , transform = IdentityTransform (), name = "part" ))
2433+ catalog .create_namespace ("default" )
2434+ table = catalog .create_table ("default.test_partition_in_struct" , schema = schema , partition_spec = spec )
2435+ test_data = [
2436+ {"foo" : "a" , "bar" : {"baz" : "data-a" , "qux" : 1 }},
2437+ {"foo" : "b" , "bar" : {"baz" : "data-b" , "qux" : 2 }},
2438+ ]
2439+
2440+ arrow_table = pa .Table .from_pylist (test_data , schema = table .schema ().as_arrow ())
2441+ table .append (arrow_table )
2442+ partitions_table = table .inspect .partitions ()
2443+ partitions = partitions_table ["partition" ].to_pylist ()
2444+
2445+ assert len (partitions ) == 2
2446+ assert {part ["part" ] for part in partitions } == {"data-a" , "data-b" }
2447+
2448+
24192449def test_identity_partition_on_multi_columns () -> None :
24202450 test_pa_schema = pa .schema ([("born_year" , pa .int64 ()), ("n_legs" , pa .int64 ()), ("animal" , pa .string ())])
24212451 test_schema = Schema (
0 commit comments