@@ -1047,13 +1047,15 @@ pub(crate) mod tests {
1047
1047
use arrow:: array:: Int32Array ;
1048
1048
use arrow:: compute:: SortOptions ;
1049
1049
use arrow:: datatypes:: { DataType , Field } ;
1050
- use datafusion_common:: { assert_batches_sorted_eq, assert_contains, ScalarValue } ;
1050
+ use datafusion_common:: test_util:: batches_to_sort_string;
1051
+ use datafusion_common:: { assert_contains, ScalarValue } ;
1051
1052
use datafusion_execution:: runtime_env:: RuntimeEnvBuilder ;
1052
1053
use datafusion_expr:: Operator ;
1053
1054
use datafusion_physical_expr:: expressions:: { BinaryExpr , Literal } ;
1054
1055
use datafusion_physical_expr:: { Partitioning , PhysicalExpr } ;
1055
1056
use datafusion_physical_expr_common:: sort_expr:: { LexOrdering , PhysicalSortExpr } ;
1056
1057
1058
+ use insta:: assert_snapshot;
1057
1059
use rstest:: rstest;
1058
1060
1059
1061
fn build_table (
@@ -1216,15 +1218,13 @@ pub(crate) mod tests {
1216
1218
)
1217
1219
. await ?;
1218
1220
assert_eq ! ( columns, vec![ "a1" , "b1" , "c1" , "a2" , "b2" , "c2" ] ) ;
1219
- let expected = [
1220
- "+----+----+----+----+----+----+" ,
1221
- "| a1 | b1 | c1 | a2 | b2 | c2 |" ,
1222
- "+----+----+----+----+----+----+" ,
1223
- "| 5 | 5 | 50 | 2 | 2 | 80 |" ,
1224
- "+----+----+----+----+----+----+" ,
1225
- ] ;
1226
-
1227
- assert_batches_sorted_eq ! ( expected, & batches) ;
1221
+ assert_snapshot ! ( batches_to_sort_string( & batches) , @r#"
1222
+ +----+----+----+----+----+----+
1223
+ | a1 | b1 | c1 | a2 | b2 | c2 |
1224
+ +----+----+----+----+----+----+
1225
+ | 5 | 5 | 50 | 2 | 2 | 80 |
1226
+ +----+----+----+----+----+----+
1227
+ "# ) ;
1228
1228
1229
1229
Ok ( ( ) )
1230
1230
}
@@ -1245,17 +1245,15 @@ pub(crate) mod tests {
1245
1245
)
1246
1246
. await ?;
1247
1247
assert_eq ! ( columns, vec![ "a1" , "b1" , "c1" , "a2" , "b2" , "c2" ] ) ;
1248
- let expected = [
1249
- "+----+----+-----+----+----+----+" ,
1250
- "| a1 | b1 | c1 | a2 | b2 | c2 |" ,
1251
- "+----+----+-----+----+----+----+" ,
1252
- "| 11 | 8 | 110 | | | |" ,
1253
- "| 5 | 5 | 50 | 2 | 2 | 80 |" ,
1254
- "| 9 | 8 | 90 | | | |" ,
1255
- "+----+----+-----+----+----+----+" ,
1256
- ] ;
1257
-
1258
- assert_batches_sorted_eq ! ( expected, & batches) ;
1248
+ assert_snapshot ! ( batches_to_sort_string( & batches) , @r#"
1249
+ +----+----+-----+----+----+----+
1250
+ | a1 | b1 | c1 | a2 | b2 | c2 |
1251
+ +----+----+-----+----+----+----+
1252
+ | 11 | 8 | 110 | | | |
1253
+ | 5 | 5 | 50 | 2 | 2 | 80 |
1254
+ | 9 | 8 | 90 | | | |
1255
+ +----+----+-----+----+----+----+
1256
+ "# ) ;
1259
1257
1260
1258
Ok ( ( ) )
1261
1259
}
@@ -1276,17 +1274,15 @@ pub(crate) mod tests {
1276
1274
)
1277
1275
. await ?;
1278
1276
assert_eq ! ( columns, vec![ "a1" , "b1" , "c1" , "a2" , "b2" , "c2" ] ) ;
1279
- let expected = [
1280
- "+----+----+----+----+----+-----+" ,
1281
- "| a1 | b1 | c1 | a2 | b2 | c2 |" ,
1282
- "+----+----+----+----+----+-----+" ,
1283
- "| | | | 10 | 10 | 100 |" ,
1284
- "| | | | 12 | 10 | 40 |" ,
1285
- "| 5 | 5 | 50 | 2 | 2 | 80 |" ,
1286
- "+----+----+----+----+----+-----+" ,
1287
- ] ;
1288
-
1289
- assert_batches_sorted_eq ! ( expected, & batches) ;
1277
+ assert_snapshot ! ( batches_to_sort_string( & batches) , @r#"
1278
+ +----+----+----+----+----+-----+
1279
+ | a1 | b1 | c1 | a2 | b2 | c2 |
1280
+ +----+----+----+----+----+-----+
1281
+ | | | | 10 | 10 | 100 |
1282
+ | | | | 12 | 10 | 40 |
1283
+ | 5 | 5 | 50 | 2 | 2 | 80 |
1284
+ +----+----+----+----+----+-----+
1285
+ "# ) ;
1290
1286
1291
1287
Ok ( ( ) )
1292
1288
}
@@ -1307,19 +1303,17 @@ pub(crate) mod tests {
1307
1303
)
1308
1304
. await ?;
1309
1305
assert_eq ! ( columns, vec![ "a1" , "b1" , "c1" , "a2" , "b2" , "c2" ] ) ;
1310
- let expected = [
1311
- "+----+----+-----+----+----+-----+" ,
1312
- "| a1 | b1 | c1 | a2 | b2 | c2 |" ,
1313
- "+----+----+-----+----+----+-----+" ,
1314
- "| | | | 10 | 10 | 100 |" ,
1315
- "| | | | 12 | 10 | 40 |" ,
1316
- "| 11 | 8 | 110 | | | |" ,
1317
- "| 5 | 5 | 50 | 2 | 2 | 80 |" ,
1318
- "| 9 | 8 | 90 | | | |" ,
1319
- "+----+----+-----+----+----+-----+" ,
1320
- ] ;
1321
-
1322
- assert_batches_sorted_eq ! ( expected, & batches) ;
1306
+ assert_snapshot ! ( batches_to_sort_string( & batches) , @r#"
1307
+ +----+----+-----+----+----+-----+
1308
+ | a1 | b1 | c1 | a2 | b2 | c2 |
1309
+ +----+----+-----+----+----+-----+
1310
+ | | | | 10 | 10 | 100 |
1311
+ | | | | 12 | 10 | 40 |
1312
+ | 11 | 8 | 110 | | | |
1313
+ | 5 | 5 | 50 | 2 | 2 | 80 |
1314
+ | 9 | 8 | 90 | | | |
1315
+ +----+----+-----+----+----+-----+
1316
+ "# ) ;
1323
1317
1324
1318
Ok ( ( ) )
1325
1319
}
@@ -1340,15 +1334,13 @@ pub(crate) mod tests {
1340
1334
)
1341
1335
. await ?;
1342
1336
assert_eq ! ( columns, vec![ "a1" , "b1" , "c1" ] ) ;
1343
- let expected = [
1344
- "+----+----+----+" ,
1345
- "| a1 | b1 | c1 |" ,
1346
- "+----+----+----+" ,
1347
- "| 5 | 5 | 50 |" ,
1348
- "+----+----+----+" ,
1349
- ] ;
1350
-
1351
- assert_batches_sorted_eq ! ( expected, & batches) ;
1337
+ assert_snapshot ! ( batches_to_sort_string( & batches) , @r#"
1338
+ +----+----+----+
1339
+ | a1 | b1 | c1 |
1340
+ +----+----+----+
1341
+ | 5 | 5 | 50 |
1342
+ +----+----+----+
1343
+ "# ) ;
1352
1344
1353
1345
Ok ( ( ) )
1354
1346
}
@@ -1369,16 +1361,14 @@ pub(crate) mod tests {
1369
1361
)
1370
1362
. await ?;
1371
1363
assert_eq ! ( columns, vec![ "a1" , "b1" , "c1" ] ) ;
1372
- let expected = [
1373
- "+----+----+-----+" ,
1374
- "| a1 | b1 | c1 |" ,
1375
- "+----+----+-----+" ,
1376
- "| 11 | 8 | 110 |" ,
1377
- "| 9 | 8 | 90 |" ,
1378
- "+----+----+-----+" ,
1379
- ] ;
1380
-
1381
- assert_batches_sorted_eq ! ( expected, & batches) ;
1364
+ assert_snapshot ! ( batches_to_sort_string( & batches) , @r#"
1365
+ +----+----+-----+
1366
+ | a1 | b1 | c1 |
1367
+ +----+----+-----+
1368
+ | 11 | 8 | 110 |
1369
+ | 9 | 8 | 90 |
1370
+ +----+----+-----+
1371
+ "# ) ;
1382
1372
1383
1373
Ok ( ( ) )
1384
1374
}
@@ -1399,15 +1389,13 @@ pub(crate) mod tests {
1399
1389
)
1400
1390
. await ?;
1401
1391
assert_eq ! ( columns, vec![ "a2" , "b2" , "c2" ] ) ;
1402
- let expected = [
1403
- "+----+----+----+" ,
1404
- "| a2 | b2 | c2 |" ,
1405
- "+----+----+----+" ,
1406
- "| 2 | 2 | 80 |" ,
1407
- "+----+----+----+" ,
1408
- ] ;
1409
-
1410
- assert_batches_sorted_eq ! ( expected, & batches) ;
1392
+ assert_snapshot ! ( batches_to_sort_string( & batches) , @r#"
1393
+ +----+----+----+
1394
+ | a2 | b2 | c2 |
1395
+ +----+----+----+
1396
+ | 2 | 2 | 80 |
1397
+ +----+----+----+
1398
+ "# ) ;
1411
1399
1412
1400
Ok ( ( ) )
1413
1401
}
@@ -1428,16 +1416,14 @@ pub(crate) mod tests {
1428
1416
)
1429
1417
. await ?;
1430
1418
assert_eq ! ( columns, vec![ "a2" , "b2" , "c2" ] ) ;
1431
- let expected = [
1432
- "+----+----+-----+" ,
1433
- "| a2 | b2 | c2 |" ,
1434
- "+----+----+-----+" ,
1435
- "| 10 | 10 | 100 |" ,
1436
- "| 12 | 10 | 40 |" ,
1437
- "+----+----+-----+" ,
1438
- ] ;
1439
-
1440
- assert_batches_sorted_eq ! ( expected, & batches) ;
1419
+ assert_snapshot ! ( batches_to_sort_string( & batches) , @r#"
1420
+ +----+----+-----+
1421
+ | a2 | b2 | c2 |
1422
+ +----+----+-----+
1423
+ | 10 | 10 | 100 |
1424
+ | 12 | 10 | 40 |
1425
+ +----+----+-----+
1426
+ "# ) ;
1441
1427
1442
1428
Ok ( ( ) )
1443
1429
}
@@ -1458,17 +1444,15 @@ pub(crate) mod tests {
1458
1444
)
1459
1445
. await ?;
1460
1446
assert_eq ! ( columns, vec![ "a1" , "b1" , "c1" , "mark" ] ) ;
1461
- let expected = [
1462
- "+----+----+-----+-------+" ,
1463
- "| a1 | b1 | c1 | mark |" ,
1464
- "+----+----+-----+-------+" ,
1465
- "| 11 | 8 | 110 | false |" ,
1466
- "| 5 | 5 | 50 | true |" ,
1467
- "| 9 | 8 | 90 | false |" ,
1468
- "+----+----+-----+-------+" ,
1469
- ] ;
1470
-
1471
- assert_batches_sorted_eq ! ( expected, & batches) ;
1447
+ assert_snapshot ! ( batches_to_sort_string( & batches) , @r#"
1448
+ +----+----+-----+-------+
1449
+ | a1 | b1 | c1 | mark |
1450
+ +----+----+-----+-------+
1451
+ | 11 | 8 | 110 | false |
1452
+ | 5 | 5 | 50 | true |
1453
+ | 9 | 8 | 90 | false |
1454
+ +----+----+-----+-------+
1455
+ "# ) ;
1472
1456
1473
1457
Ok ( ( ) )
1474
1458
}
0 commit comments