@@ -1294,7 +1294,7 @@ mod tests {
12941294
12951295 #[ test]
12961296 fn test_coerce_field_struct ( ) {
1297- use deltalake:: arrow:: datatypes:: * ;
1297+ use deltalake:: arrow:: datatypes:: { DataType , Field , TimeUnit } ;
12981298 let field = Field :: new (
12991299 "meta" ,
13001300 DataType :: Struct (
@@ -1326,15 +1326,40 @@ mod tests {
13261326 ) ;
13271327
13281328 let coerced = coerce_field ( Arc :: new ( field) ) ;
1329- let formatted = format ! ( "{}" , coerced) ;
1329+ let arrow_schema = ArrowSchema :: new ( vec ! [ coerced] ) ;
13301330
1331- assert ! (
1332- formatted. contains( "Timestamp(Microsecond" ) ,
1333- "Expected to find a Timestamp(Microsecond) in the coerced schema, got: {formatted}"
1331+ let delta_schema =
1332+ Schema :: try_from ( & arrow_schema) . expect ( "Failed to convert to delta schema" ) ;
1333+ let field = delta_schema. fields ( ) . next ( ) . expect ( "No fields found" ) ;
1334+
1335+ assert_eq ! ( field. name( ) , "meta" ) ;
1336+ assert_eq ! (
1337+ field. data_type( ) . to_string( ) ,
1338+ "struct<timestamp_ns: timestamp_ntz, timestamp_ms: timestamp_ntz, timestamps: array<timestamp_ntz>, id: integer>"
13341339 ) ;
1335- assert ! (
1336- !formatted. contains( "Timestamp(Nanosecond" ) ,
1337- "Expected to not find a Timestamp(Nanosecond) in the coerced schema, got: {formatted}"
1340+ }
1341+
1342+ #[ test]
1343+ fn test_coerce_field_list ( ) {
1344+ use deltalake:: arrow:: datatypes:: { DataType , Field , TimeUnit } ;
1345+ let field = Field :: new (
1346+ "timestamps" ,
1347+ DataType :: List ( Arc :: new ( Field :: new (
1348+ "array_item" ,
1349+ DataType :: Timestamp ( TimeUnit :: Nanosecond , None ) ,
1350+ true ,
1351+ ) ) ) ,
1352+ true ,
13381353 ) ;
1354+
1355+ let coerced = coerce_field ( Arc :: new ( field) ) ;
1356+ let arrow_schema = ArrowSchema :: new ( vec ! [ coerced] ) ;
1357+
1358+ let delta_schema =
1359+ Schema :: try_from ( & arrow_schema) . expect ( "Failed to convert to delta schema" ) ;
1360+ let field = delta_schema. fields ( ) . next ( ) . expect ( "No fields found" ) ;
1361+
1362+ assert_eq ! ( field. name( ) , "timestamps" ) ;
1363+ assert_eq ! ( field. data_type( ) . to_string( ) , "array<timestamp_ntz>" ) ;
13391364 }
13401365}
0 commit comments