This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new c0d4ae7fcc polish MemoryStream related code (#14537)
c0d4ae7fcc is described below

commit c0d4ae7fcc654ec5625ee9b1cd7ce1312f294afc
Author: zjregee <[email protected]>
AuthorDate: Sat Feb 8 02:49:05 2025 +0800

    polish MemoryStream related code (#14537)
---
 datafusion/physical-plan/src/memory.rs                        | 8 +++-----
 datafusion/sqllogictest/test_files/string/dictionary_utf8.slt | 2 +-
 datafusion/sqllogictest/test_files/string/large_string.slt    | 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/datafusion/physical-plan/src/memory.rs 
b/datafusion/physical-plan/src/memory.rs
index 5607ad9e2a..9d5d65d4e1 100644
--- a/datafusion/physical-plan/src/memory.rs
+++ b/datafusion/physical-plan/src/memory.rs
@@ -726,7 +726,7 @@ pub struct MemoryStream {
     projection: Option<Vec<usize>>,
     /// Index into the data
     index: usize,
-    /// The remaining number of rows to return
+    /// The remaining number of rows to return. If None, all rows are returned
     fetch: Option<usize>,
 }
 
@@ -778,11 +778,9 @@ impl Stream for MemoryStream {
             None => batch.clone(),
         };
 
-        if self.fetch.is_none() {
+        let Some(&fetch) = self.fetch.as_ref() else {
             return Poll::Ready(Some(Ok(batch)));
-        }
-
-        let fetch = self.fetch.unwrap();
+        };
         if fetch == 0 {
             return Poll::Ready(None);
         }
diff --git a/datafusion/sqllogictest/test_files/string/dictionary_utf8.slt 
b/datafusion/sqllogictest/test_files/string/dictionary_utf8.slt
index 2f12e9c7a3..99271a28f9 100644
--- a/datafusion/sqllogictest/test_files/string/dictionary_utf8.slt
+++ b/datafusion/sqllogictest/test_files/string/dictionary_utf8.slt
@@ -67,4 +67,4 @@ statement ok
 drop table test_substr_base;
 
 statement ok
-drop table test_datetime_base;
\ No newline at end of file
+drop table test_datetime_base;
diff --git a/datafusion/sqllogictest/test_files/string/large_string.slt 
b/datafusion/sqllogictest/test_files/string/large_string.slt
index 93ec796ec6..9126a80383 100644
--- a/datafusion/sqllogictest/test_files/string/large_string.slt
+++ b/datafusion/sqllogictest/test_files/string/large_string.slt
@@ -75,4 +75,4 @@ statement ok
 drop table test_substr_base;
 
 statement ok
-drop table test_datetime_base;
\ No newline at end of file
+drop table test_datetime_base;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to