@@ -107,10 +107,8 @@ pub(crate) mod test_util {
107107mod tests {
108108
109109 use std:: fmt:: { self , Display , Formatter } ;
110- use std:: pin:: Pin ;
111110 use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
112111 use std:: sync:: Arc ;
113- use std:: task:: { Context , Poll } ;
114112 use std:: time:: Duration ;
115113
116114 use crate :: datasource:: file_format:: parquet:: test_util:: store_parquet;
@@ -120,7 +118,7 @@ mod tests {
120118 use crate :: prelude:: { ParquetReadOptions , SessionConfig , SessionContext } ;
121119
122120 use arrow:: array:: RecordBatch ;
123- use arrow_schema:: { Schema , SchemaRef } ;
121+ use arrow_schema:: Schema ;
124122 use datafusion_catalog:: Session ;
125123 use datafusion_common:: cast:: {
126124 as_binary_array, as_binary_view_array, as_boolean_array, as_float32_array,
@@ -140,7 +138,7 @@ mod tests {
140138 } ;
141139 use datafusion_execution:: object_store:: ObjectStoreUrl ;
142140 use datafusion_execution:: runtime_env:: RuntimeEnv ;
143- use datafusion_execution:: { RecordBatchStream , TaskContext } ;
141+ use datafusion_execution:: TaskContext ;
144142 use datafusion_expr:: dml:: InsertOp ;
145143 use datafusion_physical_plan:: stream:: RecordBatchStreamAdapter ;
146144 use datafusion_physical_plan:: { collect, ExecutionPlan } ;
@@ -153,7 +151,7 @@ mod tests {
153151 use async_trait:: async_trait;
154152 use datafusion_datasource:: file_groups:: FileGroup ;
155153 use futures:: stream:: BoxStream ;
156- use futures:: { Stream , StreamExt } ;
154+ use futures:: StreamExt ;
157155 use insta:: assert_snapshot;
158156 use log:: error;
159157 use object_store:: local:: LocalFileSystem ;
@@ -169,6 +167,8 @@ mod tests {
169167 use parquet:: format:: FileMetaData ;
170168 use tokio:: fs:: File ;
171169
170+ use crate :: test_util:: bounded_stream;
171+
172172 enum ForceViews {
173173 Yes ,
174174 No ,
@@ -1662,43 +1662,4 @@ mod tests {
16621662
16631663 Ok ( ( ) )
16641664 }
1665-
1666- /// Creates an bounded stream for testing purposes.
1667- fn bounded_stream (
1668- batch : RecordBatch ,
1669- limit : usize ,
1670- ) -> datafusion_execution:: SendableRecordBatchStream {
1671- Box :: pin ( BoundedStream {
1672- count : 0 ,
1673- limit,
1674- batch,
1675- } )
1676- }
1677-
1678- struct BoundedStream {
1679- limit : usize ,
1680- count : usize ,
1681- batch : RecordBatch ,
1682- }
1683-
1684- impl Stream for BoundedStream {
1685- type Item = Result < RecordBatch > ;
1686-
1687- fn poll_next (
1688- mut self : Pin < & mut Self > ,
1689- _cx : & mut Context < ' _ > ,
1690- ) -> Poll < Option < Self :: Item > > {
1691- if self . count >= self . limit {
1692- return Poll :: Ready ( None ) ;
1693- }
1694- self . count += 1 ;
1695- Poll :: Ready ( Some ( Ok ( self . batch . clone ( ) ) ) )
1696- }
1697- }
1698-
1699- impl RecordBatchStream for BoundedStream {
1700- fn schema ( & self ) -> SchemaRef {
1701- self . batch . schema ( )
1702- }
1703- }
17041665}
0 commit comments