|
16 | 16 | // under the License. |
17 | 17 |
|
18 | 18 | use arrow::array::RecordBatch; |
| 19 | +use datafusion::common::test_util::batches_to_string; |
19 | 20 | use std::sync::Arc; |
20 | 21 |
|
21 | | -use datafusion::common::{assert_batches_eq, DFSchema}; |
| 22 | +use datafusion::common::DFSchema; |
22 | 23 | use datafusion::error::Result; |
23 | 24 | use datafusion::execution::FunctionRegistry; |
24 | 25 | use datafusion::logical_expr::Operator; |
@@ -76,49 +77,51 @@ async fn plan_and_collect(sql: &str) -> Result<Vec<RecordBatch>> { |
76 | 77 | #[tokio::test] |
77 | 78 | async fn test_custom_operators_arrow() { |
78 | 79 | let actual = plan_and_collect("select 'foo'->'bar';").await.unwrap(); |
79 | | - let expected = [ |
80 | | - "+----------------------------+", |
81 | | - "| Utf8(\"foo\") || Utf8(\"bar\") |", |
82 | | - "+----------------------------+", |
83 | | - "| foobar |", |
84 | | - "+----------------------------+", |
85 | | - ]; |
86 | | - assert_batches_eq!(&expected, &actual); |
| 80 | + insta::assert_snapshot!(batches_to_string(&actual), @r###" |
| 81 | + +----------------------------+ |
| 82 | + | Utf8("foo") || Utf8("bar") | |
| 83 | + +----------------------------+ |
| 84 | + | foobar | |
| 85 | + +----------------------------+ |
| 86 | + "###); |
87 | 87 | } |
88 | 88 |
|
89 | 89 | #[tokio::test] |
90 | 90 | async fn test_custom_operators_long_arrow() { |
91 | 91 | let actual = plan_and_collect("select 1->>2;").await.unwrap(); |
92 | | - let expected = [ |
93 | | - "+---------------------+", |
94 | | - "| Int64(1) + Int64(2) |", |
95 | | - "+---------------------+", |
96 | | - "| 3 |", |
97 | | - "+---------------------+", |
98 | | - ]; |
99 | | - assert_batches_eq!(&expected, &actual); |
| 92 | + insta::assert_snapshot!(batches_to_string(&actual), @r###" |
| 93 | + +---------------------+ |
| 94 | + | Int64(1) + Int64(2) | |
| 95 | + +---------------------+ |
| 96 | + | 3 | |
| 97 | + +---------------------+ |
| 98 | + "###); |
100 | 99 | } |
101 | 100 |
|
102 | 101 | #[tokio::test] |
103 | 102 | async fn test_question_select() { |
104 | 103 | let actual = plan_and_collect("select a ? 2 from (select 1 as a);") |
105 | 104 | .await |
106 | 105 | .unwrap(); |
107 | | - let expected = [ |
108 | | - "+--------------+", |
109 | | - "| a ? Int64(2) |", |
110 | | - "+--------------+", |
111 | | - "| true |", |
112 | | - "+--------------+", |
113 | | - ]; |
114 | | - assert_batches_eq!(&expected, &actual); |
| 106 | + insta::assert_snapshot!(batches_to_string(&actual), @r###" |
| 107 | + +--------------+ |
| 108 | + | a ? Int64(2) | |
| 109 | + +--------------+ |
| 110 | + | true | |
| 111 | + +--------------+ |
| 112 | + "###); |
115 | 113 | } |
116 | 114 |
|
117 | 115 | #[tokio::test] |
118 | 116 | async fn test_question_filter() { |
119 | 117 | let actual = plan_and_collect("select a from (select 1 as a) where a ? 2;") |
120 | 118 | .await |
121 | 119 | .unwrap(); |
122 | | - let expected = ["+---+", "| a |", "+---+", "| 1 |", "+---+"]; |
123 | | - assert_batches_eq!(&expected, &actual); |
| 120 | + insta::assert_snapshot!(batches_to_string(&actual), @r###" |
| 121 | + +---+ |
| 122 | + | a | |
| 123 | + +---+ |
| 124 | + | 1 | |
| 125 | + +---+ |
| 126 | + "###); |
124 | 127 | } |
0 commit comments