Skip to content

Commit 1615551

Browse files
committed
update view_test
1 parent f9261ba commit 1615551

3 files changed

Lines changed: 136 additions & 148 deletions

File tree

datafusion/core/src/datasource/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ mod tests {
6060
use arrow::array::{Int32Array, StringArray};
6161
use arrow::datatypes::{DataType, Field, Schema, SchemaRef};
6262
use arrow::record_batch::RecordBatch;
63-
use datafusion_common::assert_batches_sorted_eq;
63+
use datafusion_common::test_util::batches_to_sort_string;
6464
use datafusion_datasource::file_scan_config::FileScanConfig;
6565
use datafusion_datasource::schema_adapter::{
6666
DefaultSchemaAdapterFactory, SchemaAdapter, SchemaAdapterFactory, SchemaMapper,
@@ -138,15 +138,13 @@ mod tests {
138138
let task_ctx = session_ctx.task_ctx();
139139
let read = collect(parquet_exec, task_ctx).await.unwrap();
140140

141-
let expected = [
142-
"+----+--------------+",
143-
"| id | extra_column |",
144-
"+----+--------------+",
145-
"| 1 | foo |",
146-
"+----+--------------+",
147-
];
148-
149-
assert_batches_sorted_eq!(expected, &read);
141+
insta::assert_snapshot!(batches_to_sort_string(&read),@r###"
142+
+----+--------------+
143+
| id | extra_column |
144+
+----+--------------+
145+
| 1 | foo |
146+
+----+--------------+
147+
"###);
150148
}
151149

152150
#[test]

datafusion/core/src/datasource/physical_plan/parquet.rs

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ mod tests {
269269
.round_trip(vec![batch.clone()])
270270
.await;
271271
let batches = rt.batches.unwrap();
272-
#[rustfmt::skip]
273-
let expected = [
274-
"+----+----+",
275-
"| c1 | c2 |",
276-
"+----+----+",
277-
"| 1 | |",
278-
"+----+----+",
279-
];
280-
assert_batches_sorted_eq!(expected, &batches);
272+
273+
insta::assert_snapshot!(batches_to_sort_string(&batches),@r###"
274+
+----+----+
275+
| c1 | c2 |
276+
+----+----+
277+
| 1 | |
278+
+----+----+
279+
"###);
280+
281281
let metrics = rt.parquet_exec.metrics().unwrap();
282282
let metric = get_value(&metrics, "pushdown_rows_pruned");
283283
assert_eq!(metric, 2, "Expected all rows to be pruned");
@@ -327,15 +327,15 @@ mod tests {
327327
.round_trip(vec![batch.clone()])
328328
.await;
329329
let batches = rt.batches.unwrap();
330-
#[rustfmt::skip]
331-
let expected = [
332-
"+----+----+",
333-
"| c1 | c2 |",
334-
"+----+----+",
335-
"| 1 | |",
336-
"+----+----+",
337-
];
338-
assert_batches_sorted_eq!(expected, &batches);
330+
331+
insta::assert_snapshot!(batches_to_sort_string(&batches),@r###"
332+
+----+----+
333+
| c1 | c2 |
334+
+----+----+
335+
| 1 | |
336+
+----+----+
337+
"###);
338+
339339
let metrics = rt.parquet_exec.metrics().unwrap();
340340
let metric = get_value(&metrics, "pushdown_rows_pruned");
341341
assert_eq!(metric, 2, "Expected all rows to be pruned");
@@ -389,15 +389,15 @@ mod tests {
389389
.round_trip(vec![batch.clone()])
390390
.await;
391391
let batches = rt.batches.unwrap();
392-
#[rustfmt::skip]
393-
let expected = [
394-
"+----+----+----+",
395-
"| c1 | c2 | c3 |",
396-
"+----+----+----+",
397-
"| 1 | | 7 |",
398-
"+----+----+----+",
399-
];
400-
assert_batches_sorted_eq!(expected, &batches);
392+
393+
insta::assert_snapshot!(batches_to_sort_string(&batches),@r###"
394+
+----+----+----+
395+
| c1 | c2 | c3 |
396+
+----+----+----+
397+
| 1 | | 7 |
398+
+----+----+----+
399+
"###);
400+
401401
let metrics = rt.parquet_exec.metrics().unwrap();
402402
let metric = get_value(&metrics, "pushdown_rows_pruned");
403403
assert_eq!(metric, 2, "Expected all rows to be pruned");
@@ -451,15 +451,15 @@ mod tests {
451451
.round_trip(vec![batch.clone()])
452452
.await;
453453
let batches = rt.batches.unwrap();
454-
#[rustfmt::skip]
455-
let expected = [
456-
"+----+----+----+",
457-
"| c1 | c2 | c3 |",
458-
"+----+----+----+",
459-
"| | | 7 |",
460-
"+----+----+----+",
461-
];
462-
assert_batches_sorted_eq!(expected, &batches);
454+
455+
insta::assert_snapshot!(batches_to_sort_string(&batches),@r###"
456+
+----+----+----+
457+
| c1 | c2 | c3 |
458+
+----+----+----+
459+
| | | 7 |
460+
+----+----+----+
461+
"###);
462+
463463
let metrics = rt.parquet_exec.metrics().unwrap();
464464
let metric = get_value(&metrics, "pushdown_rows_pruned");
465465
assert_eq!(metric, 2, "Expected all rows to be pruned");
@@ -500,15 +500,15 @@ mod tests {
500500
.await;
501501

502502
let batches = rt.batches.unwrap();
503-
#[rustfmt::skip]
504-
let expected = [
505-
"+----+----+----+",
506-
"| c1 | c2 | c3 |",
507-
"+----+----+----+",
508-
"| 1 | | 10 |",
509-
"+----+----+----+",
510-
];
511-
assert_batches_sorted_eq!(expected, &batches);
503+
504+
insta::assert_snapshot!(batches_to_sort_string(&batches),@r###"
505+
+----+----+----+
506+
| c1 | c2 | c3 |
507+
+----+----+----+
508+
| 1 | | 10 |
509+
+----+----+----+
510+
"###);
511+
512512
let metrics = rt.parquet_exec.metrics().unwrap();
513513
let metric = get_value(&metrics, "pushdown_rows_pruned");
514514
assert_eq!(metric, 4, "Expected 4 rows to be pruned");
@@ -530,17 +530,17 @@ mod tests {
530530
.await;
531531

532532
let batches = rt.batches.unwrap();
533-
#[rustfmt::skip]
534-
let expected = [
535-
"+----+----+----+",
536-
"| c1 | c2 | c3 |",
537-
"+----+----+----+",
538-
"| 3 | | 30 |",
539-
"| 4 | | 40 |",
540-
"| 5 | | 50 |",
541-
"+----+----+----+",
542-
];
543-
assert_batches_sorted_eq!(expected, &batches);
533+
534+
insta::assert_snapshot!(batches_to_sort_string(&batches),@r###"
535+
+----+----+----+
536+
| c1 | c2 | c3 |
537+
+----+----+----+
538+
| 3 | | 30 |
539+
| 4 | | 40 |
540+
| 5 | | 50 |
541+
+----+----+----+
542+
"###);
543+
544544
let metrics = rt.parquet_exec.metrics().unwrap();
545545
let metric = get_value(&metrics, "pushdown_rows_pruned");
546546
assert_eq!(metric, 2, "Expected 2 rows to be pruned");

0 commit comments

Comments
 (0)