@@ -1047,13 +1047,15 @@ pub(crate) mod tests {
10471047 use arrow:: array:: Int32Array ;
10481048 use arrow:: compute:: SortOptions ;
10491049 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 } ;
10511052 use datafusion_execution:: runtime_env:: RuntimeEnvBuilder ;
10521053 use datafusion_expr:: Operator ;
10531054 use datafusion_physical_expr:: expressions:: { BinaryExpr , Literal } ;
10541055 use datafusion_physical_expr:: { Partitioning , PhysicalExpr } ;
10551056 use datafusion_physical_expr_common:: sort_expr:: { LexOrdering , PhysicalSortExpr } ;
10561057
1058+ use insta:: assert_snapshot;
10571059 use rstest:: rstest;
10581060
10591061 fn build_table (
@@ -1216,15 +1218,13 @@ pub(crate) mod tests {
12161218 )
12171219 . await ?;
12181220 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+ "# ) ;
12281228
12291229 Ok ( ( ) )
12301230 }
@@ -1245,17 +1245,15 @@ pub(crate) mod tests {
12451245 )
12461246 . await ?;
12471247 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+ "# ) ;
12591257
12601258 Ok ( ( ) )
12611259 }
@@ -1276,17 +1274,15 @@ pub(crate) mod tests {
12761274 )
12771275 . await ?;
12781276 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+ "# ) ;
12901286
12911287 Ok ( ( ) )
12921288 }
@@ -1307,19 +1303,17 @@ pub(crate) mod tests {
13071303 )
13081304 . await ?;
13091305 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+ "# ) ;
13231317
13241318 Ok ( ( ) )
13251319 }
@@ -1340,15 +1334,13 @@ pub(crate) mod tests {
13401334 )
13411335 . await ?;
13421336 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+ "# ) ;
13521344
13531345 Ok ( ( ) )
13541346 }
@@ -1369,16 +1361,14 @@ pub(crate) mod tests {
13691361 )
13701362 . await ?;
13711363 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+ "# ) ;
13821372
13831373 Ok ( ( ) )
13841374 }
@@ -1399,15 +1389,13 @@ pub(crate) mod tests {
13991389 )
14001390 . await ?;
14011391 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+ "# ) ;
14111399
14121400 Ok ( ( ) )
14131401 }
@@ -1428,16 +1416,14 @@ pub(crate) mod tests {
14281416 )
14291417 . await ?;
14301418 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+ "# ) ;
14411427
14421428 Ok ( ( ) )
14431429 }
@@ -1458,17 +1444,15 @@ pub(crate) mod tests {
14581444 )
14591445 . await ?;
14601446 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+ "# ) ;
14721456
14731457 Ok ( ( ) )
14741458 }
0 commit comments