Execute the plan and return a stream of `RecordBatch`es for the specified partition.
(
&self,
partition: usize,
context: Arc<TaskContext>,
)
| 226 | /// Execute the plan and return a stream of `RecordBatch`es for |
| 227 | /// the specified partition. |
| 228 | fn execute( |
| 229 | &self, |
| 230 | partition: usize, |
| 231 | context: Arc<TaskContext>, |
| 232 | ) -> Result<SendableRecordBatchStream> { |
| 233 | assert_eq_or_internal_err!( |
| 234 | partition, |
| 235 | 0, |
| 236 | "DataSinkExec can only be called on partition 0!" |
| 237 | ); |
| 238 | let data = execute_input_stream( |
| 239 | Arc::clone(&self.input), |
| 240 | Arc::clone(self.sink.schema()), |
| 241 | 0, |
| 242 | Arc::clone(&context), |
| 243 | )?; |
| 244 | |
| 245 | let count_schema = Arc::clone(&self.count_schema); |
| 246 | let sink = Arc::clone(&self.sink); |
| 247 | |
| 248 | let stream = futures::stream::once(async move { |
| 249 | sink.write_all(data, &context).await.map(make_count_batch) |
| 250 | }) |
| 251 | .boxed(); |
| 252 | |
| 253 | Ok(Box::pin(RecordBatchStreamAdapter::new( |
| 254 | count_schema, |
| 255 | stream, |
| 256 | ))) |
| 257 | } |
| 258 | |
| 259 | /// Returns the metrics of the underlying [DataSink] |
| 260 | fn metrics(&self) -> Option<MetricsSet> { |
no test coverage detected