@@ -155,7 +155,9 @@ impl PartitionSpec {
155
155
true
156
156
}
157
157
158
- pub ( crate ) fn partition_to_path ( & self , data : & Struct , schema : SchemaRef ) -> String {
158
+ /// Returns partition path string containing partition type and partition
159
+ /// value as key-value pairs.
160
+ pub fn partition_to_path ( & self , data : & Struct , schema : SchemaRef ) -> String {
159
161
let partition_type = self . partition_type ( & schema) . unwrap ( ) ;
160
162
let field_types = partition_type. fields ( ) ;
161
163
@@ -1813,6 +1815,9 @@ mod tests {
1813
1815
. with_fields ( vec ! [
1814
1816
NestedField :: required( 1 , "id" , Type :: Primitive ( PrimitiveType :: Int ) ) . into( ) ,
1815
1817
NestedField :: required( 2 , "name" , Type :: Primitive ( PrimitiveType :: String ) ) . into( ) ,
1818
+ NestedField :: required( 3 , "timestamp" , Type :: Primitive ( PrimitiveType :: Timestamp ) )
1819
+ . into( ) ,
1820
+ NestedField :: required( 4 , "empty" , Type :: Primitive ( PrimitiveType :: String ) ) . into( ) ,
1816
1821
] )
1817
1822
. build ( )
1818
1823
. unwrap ( ) ;
@@ -1822,14 +1827,23 @@ mod tests {
1822
1827
. unwrap ( )
1823
1828
. add_partition_field ( "name" , "name" , Transform :: Identity )
1824
1829
. unwrap ( )
1830
+ . add_partition_field ( "timestamp" , "ts_hour" , Transform :: Hour )
1831
+ . unwrap ( )
1832
+ . add_partition_field ( "empty" , "empty_void" , Transform :: Void )
1833
+ . unwrap ( )
1825
1834
. build ( )
1826
1835
. unwrap ( ) ;
1827
1836
1828
- let data = Struct :: from_iter ( [ Some ( Literal :: int ( 42 ) ) , Some ( Literal :: string ( "alice" ) ) ] ) ;
1837
+ let data = Struct :: from_iter ( [
1838
+ Some ( Literal :: int ( 42 ) ) ,
1839
+ Some ( Literal :: string ( "alice" ) ) ,
1840
+ Some ( Literal :: int ( 1000 ) ) ,
1841
+ Some ( Literal :: string ( "empty" ) ) ,
1842
+ ] ) ;
1829
1843
1830
1844
assert_eq ! (
1831
1845
spec. partition_to_path( & data, schema. into( ) ) ,
1832
- "id=42/name=alice"
1846
+ "id=42/name=alice/ts_hour=1000/empty_void=null "
1833
1847
) ;
1834
1848
}
1835
1849
}
0 commit comments