alamb commented on code in PR #8651:
URL: https://github.com/apache/arrow-datafusion/pull/8651#discussion_r1436430116
##########
datafusion-cli/src/print_format.rs:
##########
@@ -159,14 +191,41 @@ impl PrintFormat {
}
Ok(())
}
+
+ pub fn print_stream(&self, batch: &RecordBatch, with_header: bool) ->
Result<()> {
Review Comment:
This function is almost a copy/paste of `print_batch` -- as you say in your
comments, the only difference is i Self::Table. I think it would be possible
to reduce replication by changing all this code to be in terms of the output
stream rather than creating strings
##########
datafusion-cli/src/print_options.rs:
##########
@@ -103,4 +109,28 @@ impl PrintOptions {
Ok(())
}
+
+ #[allow(clippy::println_empty_string)]
+ pub async fn print_stream(
+ &self,
+ mut stream: Pin<Box<dyn RecordBatchStream>>,
+ query_start_time: Instant,
+ ) -> Result<()> {
+ let mut row_count = 0_usize;
+ let mut with_header = true;
Review Comment:
I wonder if there is any way to test this behavior (specifically that the
header is only printed out for the first batch) so that it isn't broken in
subsequent refactorings
##########
datafusion-cli/src/print_format.rs:
##########
@@ -159,14 +191,41 @@ impl PrintFormat {
}
Ok(())
}
+
+ pub fn print_stream(&self, batch: &RecordBatch, with_header: bool) ->
Result<()> {
+ if batch.num_rows() == 0 {
+ return Ok(());
+ }
+
+ match self {
+ Self::Csv | Self::Automatic => {
+ println!("{}", print_stream_with_sep(batch, b',',
with_header)?)
+ }
+ Self::Tsv => {
+ println!("{}", print_stream_with_sep(batch, b'\t',
with_header)?)
+ }
+ Self::Table => {
Review Comment:
Another thought here is that when printing streams, it could just print out
a new Table for each batch (rather than buffering all batches).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]