File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
parquet-variant-compute/src Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -1291,8 +1291,8 @@ mod tests {
12911291 let input = builder. build ( ) ;
12921292
12931293 let target_schema = ShreddedSchemaBuilder :: default ( )
1294- . with_path ( "id" , & DataType :: FixedSizeBinary ( 16 ) )
1295- . with_path ( "session_id" , & DataType :: FixedSizeBinary ( 16 ) )
1294+ . with_path ( "id" , DataType :: FixedSizeBinary ( 16 ) )
1295+ . with_path ( "session_id" , DataType :: FixedSizeBinary ( 16 ) )
12961296 . build ( ) ;
12971297
12981298 let result = shred_variant ( & input, & target_schema) . unwrap ( ) ;
@@ -1666,6 +1666,16 @@ mod tests {
16661666 ) ;
16671667 }
16681668
1669+ #[ test]
1670+ fn test_variant_schema_builder_root_path ( ) {
1671+ let path = VariantPath :: new ( vec ! [ ] ) ;
1672+ let shredding_type = ShreddedSchemaBuilder :: default ( )
1673+ . with_path ( path, & DataType :: Int64 )
1674+ . build ( ) ;
1675+
1676+ assert_eq ! ( shredding_type, DataType :: Int64 ) ;
1677+ }
1678+
16691679 #[ test]
16701680 fn test_variant_schema_builder_empty_path ( ) {
16711681 let shredding_type = ShreddedSchemaBuilder :: default ( )
Original file line number Diff line number Diff line change @@ -103,7 +103,11 @@ impl<'a> From<Vec<VariantPathElement<'a>>> for VariantPath<'a> {
103103/// Create from &str with support for dot notation
104104impl < ' a > From < & ' a str > for VariantPath < ' a > {
105105 fn from ( path : & ' a str ) -> Self {
106- VariantPath :: new ( path. split ( '.' ) . map ( Into :: into) . collect ( ) )
106+ if path. is_empty ( ) {
107+ VariantPath :: new ( vec ! [ ] )
108+ } else {
109+ VariantPath :: new ( path. split ( '.' ) . map ( Into :: into) . collect ( ) )
110+ }
107111 }
108112}
109113
@@ -198,6 +202,12 @@ mod tests {
198202 assert ! ( path. is_empty( ) ) ;
199203 }
200204
205+ #[ test]
206+ fn test_variant_path_empty_str ( ) {
207+ let path = VariantPath :: from ( "" ) ;
208+ assert ! ( path. is_empty( ) ) ;
209+ }
210+
201211 #[ test]
202212 fn test_variant_path_non_empty ( ) {
203213 let p = VariantPathElement :: from ( "a" ) ;
You can’t perform that action at this time.
0 commit comments