diff --git a/datafusion/physical-plan/src/memory.rs b/datafusion/physical-plan/src/memory.rs index 5607ad9e2a9f..9d5d65d4e18a 100644 --- a/datafusion/physical-plan/src/memory.rs +++ b/datafusion/physical-plan/src/memory.rs @@ -726,7 +726,7 @@ pub struct MemoryStream { projection: Option>, /// 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, } @@ -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 2f12e9c7a39b..99271a28f950 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 93ec796ec6f0..9126a80383ef 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;