@@ -1191,7 +1191,7 @@ impl LogicalExtensionCodec for UDFExtensionCodec {
1191
1191
}
1192
1192
1193
1193
#[ test]
1194
- fn round_trip_scalar_values ( ) {
1194
+ fn round_trip_scalar_values_and_data_types ( ) {
1195
1195
let should_pass: Vec < ScalarValue > = vec ! [
1196
1196
ScalarValue :: Boolean ( None ) ,
1197
1197
ScalarValue :: Float32 ( None ) ,
@@ -1245,6 +1245,8 @@ fn round_trip_scalar_values() {
1245
1245
ScalarValue :: UInt64 ( Some ( 0 ) ) ,
1246
1246
ScalarValue :: Utf8 ( Some ( String :: from( "Test string " ) ) ) ,
1247
1247
ScalarValue :: LargeUtf8 ( Some ( String :: from( "Test Large utf8" ) ) ) ,
1248
+ ScalarValue :: Utf8View ( Some ( String :: from( "Test stringview" ) ) ) ,
1249
+ ScalarValue :: BinaryView ( Some ( b"binaryview" . to_vec( ) ) ) ,
1248
1250
ScalarValue :: Date32 ( Some ( 0 ) ) ,
1249
1251
ScalarValue :: Date32 ( Some ( i32 :: MAX ) ) ,
1250
1252
ScalarValue :: Date32 ( None ) ,
@@ -1471,21 +1473,38 @@ fn round_trip_scalar_values() {
1471
1473
ScalarValue :: FixedSizeBinary ( 5 , None ) ,
1472
1474
] ;
1473
1475
1474
- for test_case in should_pass. into_iter ( ) {
1475
- let proto: protobuf:: ScalarValue = ( & test_case)
1476
- . try_into ( )
1477
- . expect ( "failed conversion to protobuf" ) ;
1478
-
1476
+ // ScalarValue directly
1477
+ for test_case in should_pass. iter ( ) {
1478
+ let proto: protobuf:: ScalarValue =
1479
+ test_case. try_into ( ) . expect ( "failed conversion to protobuf" ) ;
1479
1480
let roundtrip: ScalarValue = ( & proto)
1480
1481
. try_into ( )
1481
1482
. expect ( "failed conversion from protobuf" ) ;
1482
1483
1483
1484
assert_eq ! (
1484
- test_case, roundtrip,
1485
+ test_case, & roundtrip,
1485
1486
"ScalarValue was not the same after round trip!\n \n \
1486
1487
Input: {test_case:?}\n \n Roundtrip: {roundtrip:?}"
1487
1488
) ;
1488
1489
}
1490
+
1491
+ // DataType conversion
1492
+ for test_case in should_pass. iter ( ) {
1493
+ let dt = test_case. data_type ( ) ;
1494
+
1495
+ let proto: protobuf:: ArrowType = ( & dt)
1496
+ . try_into ( )
1497
+ . expect ( "datatype failed conversion to protobuf" ) ;
1498
+ let roundtrip: DataType = ( & proto)
1499
+ . try_into ( )
1500
+ . expect ( "datatype failed conversion from protobuf" ) ;
1501
+
1502
+ assert_eq ! (
1503
+ dt, roundtrip,
1504
+ "DataType was not the same after round trip!\n \n \
1505
+ Input: {dt:?}\n \n Roundtrip: {roundtrip:?}"
1506
+ ) ;
1507
+ }
1489
1508
}
1490
1509
1491
1510
// create a map array [{joe:1}, {blogs:2, foo:4}, {}, null] for testing
0 commit comments