Print the stream to stdout using the specified format
(
&self,
mut stream: Pin<Box<dyn RecordBatchStream>>,
query_start_time: Instant,
format_options: &FormatOptions,
)
| 142 | |
| 143 | /// Print the stream to stdout using the specified format |
| 144 | pub async fn print_stream( |
| 145 | &self, |
| 146 | mut stream: Pin<Box<dyn RecordBatchStream>>, |
| 147 | query_start_time: Instant, |
| 148 | format_options: &FormatOptions, |
| 149 | ) -> Result<()> { |
| 150 | if self.format == PrintFormat::Table { |
| 151 | return Err(DataFusionError::External( |
| 152 | "PrintFormat::Table is not implemented".to_string().into(), |
| 153 | )); |
| 154 | }; |
| 155 | |
| 156 | let stdout = io::stdout(); |
| 157 | let mut writer = stdout.lock(); |
| 158 | |
| 159 | let mut row_count = 0_usize; |
| 160 | let mut with_header = true; |
| 161 | |
| 162 | while let Some(maybe_batch) = stream.next().await { |
| 163 | let batch = maybe_batch?; |
| 164 | row_count += batch.num_rows(); |
| 165 | self.format.print_batches( |
| 166 | &mut writer, |
| 167 | batch.schema(), |
| 168 | &[batch], |
| 169 | MaxRows::Unlimited, |
| 170 | with_header, |
| 171 | format_options, |
| 172 | )?; |
| 173 | with_header = false; |
| 174 | } |
| 175 | |
| 176 | let formatted_exec_details = get_execution_details_formatted( |
| 177 | row_count, |
| 178 | MaxRows::Unlimited, |
| 179 | query_start_time, |
| 180 | ); |
| 181 | |
| 182 | self.write_output(&mut writer, &formatted_exec_details) |
| 183 | } |
| 184 | |
| 185 | fn write_output<W: io::Write>( |
| 186 | &self, |
no test coverage detected