rshkv commented on code in PR #870:
URL: https://github.com/apache/iceberg-rust/pull/870#discussion_r1905304810


##########
crates/iceberg/src/metadata_scan.rs:
##########
@@ -95,7 +99,17 @@ impl<'a> SnapshotsTable<'a> {
     }
 
     /// Scans the snapshots table.
-    pub fn scan(&self) -> Result<RecordBatch> {
+    pub async fn scan(&self) -> Result<ArrowRecordBatchStream> {
+        let arrow_schema = Arc::new(self.schema());
+        let table_metadata = self.table.metadata_ref();
+
+        Ok(
+            futures::stream::once(async move { Self::build_batch(arrow_schema, 
&table_metadata) })

Review Comment:
   Sorry, I'm not sure how to do that with `stream::iter`.
   
   `stream::iter` takes an iterator but not sure what we would, conceptually, 
we iterate over (even if just a single element). We can try create an iterator 
from a closure (something like 
[`iter::from_fn`](https://doc.rust-lang.org/1.82.0/std/iter/fn.from_fn.html)) 
from which we return once but that seems more verbose.
   
   The `async move` seem necessary to me (and the compiler) because, as I 
understand, `once` takes an async function and `move` allows the closure to own 
`arrow_schema` and `table_metadata` so it can outlive the caller.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to