alamb commented on code in PR #8895:
URL: https://github.com/apache/arrow-datafusion/pull/8895#discussion_r1455399428


##########
datafusion-cli/src/print_format.rs:
##########
@@ -161,7 +161,7 @@ impl PrintFormat {
         maxrows: MaxRows,
         with_header: bool,
     ) -> Result<()> {
-        if batches.is_empty() || batches[0].num_rows() == 0 {
+        if batches.is_empty() {

Review Comment:
   This is the fix (thanks @Jefffrey for finding this). The rest of the PR is 
tests



##########
datafusion-cli/src/print_format.rs:
##########
@@ -351,4 +351,82 @@ mod tests {
 
         Ok(())
     }
+
+
+    #[test]
+    fn test_print_batches_empty_batches() -> Result<()> {
+        let batch = RecordBatch::try_from_iter(
+            vec![
+                ("a", Arc::new(Int32Array::from(vec![1, 2, 3])) as ArrayRef),
+            ],
+        )?;
+        let empty_batch = RecordBatch::new_empty(batch.schema());
+
+        PrintBatchesTest::new()
+            .with_format(PrintFormat::Table)
+            .with_batches(vec![
+                empty_batch.clone(),
+                batch,
+                empty_batch,
+            ])
+            .with_expected(
+                &[
+            "+---+",
+            "| a |",
+            "+---+",
+            "| 1 |",
+            "| 2 |",
+            "| 3 |",
+            "+---+\n",
+        ])
+            .run();
+       Ok(())
+    }
+
+    struct PrintBatchesTest {

Review Comment:
   I plan to rework the rest of the tests in this module as a follow on PR 
using this struct



-- 
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]

Reply via email to