@@ -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
@@ -1789,6 +1791,9 @@ mod tests {
1789
1791
. with_fields ( vec ! [
1790
1792
NestedField :: required( 1 , "id" , Type :: Primitive ( PrimitiveType :: Int ) ) . into( ) ,
1791
1793
NestedField :: required( 2 , "name" , Type :: Primitive ( PrimitiveType :: String ) ) . into( ) ,
1794
+ NestedField :: required( 3 , "timestamp" , Type :: Primitive ( PrimitiveType :: Timestamp ) )
1795
+ . into( ) ,
1796
+ NestedField :: required( 4 , "empty" , Type :: Primitive ( PrimitiveType :: String ) ) . into( ) ,
1792
1797
] )
1793
1798
. build ( )
1794
1799
. unwrap ( ) ;
@@ -1798,14 +1803,23 @@ mod tests {
1798
1803
. unwrap ( )
1799
1804
. add_partition_field ( "name" , "name" , Transform :: Identity )
1800
1805
. unwrap ( )
1806
+ . add_partition_field ( "timestamp" , "ts_hour" , Transform :: Hour )
1807
+ . unwrap ( )
1808
+ . add_partition_field ( "empty" , "empty_void" , Transform :: Void )
1809
+ . unwrap ( )
1801
1810
. build ( )
1802
1811
. unwrap ( ) ;
1803
1812
1804
- let data = Struct :: from_iter ( [ Some ( Literal :: int ( 42 ) ) , Some ( Literal :: string ( "alice" ) ) ] ) ;
1813
+ let data = Struct :: from_iter ( [
1814
+ Some ( Literal :: int ( 42 ) ) ,
1815
+ Some ( Literal :: string ( "alice" ) ) ,
1816
+ Some ( Literal :: int ( 1000 ) ) ,
1817
+ Some ( Literal :: string ( "empty" ) ) ,
1818
+ ] ) ;
1805
1819
1806
1820
assert_eq ! (
1807
1821
spec. partition_to_path( & data, schema. into( ) ) ,
1808
- "id=42/name=alice"
1822
+ "id=42/name=alice/ts_hour=1000/empty_void=null "
1809
1823
) ;
1810
1824
}
1811
1825
}
0 commit comments