Perseus commented on code in PR #47:
URL: https://github.com/apache/datafusion-iceberg/pull/47#discussion_r4203858452
##########
crates/datafusion/src/physical_plan/metadata_scan.rs:
##########
@@ -80,28 +92,40 @@ impl ExecutionPlan for IcebergMetadataScan {
fn apply_expressions(
&self,
- _f: &mut dyn FnMut(
- &Arc<dyn PhysicalExpr>,
- ) -> datafusion::error::Result<TreeNodeRecursion>,
- ) -> datafusion::error::Result<TreeNodeRecursion> {
+ _f: &mut dyn FnMut(&Arc<dyn PhysicalExpr>) ->
Result<TreeNodeRecursion>,
+ ) -> Result<TreeNodeRecursion> {
Ok(TreeNodeRecursion::Continue)
}
fn with_new_children(
self: Arc<Self>,
_children: Vec<Arc<dyn ExecutionPlan>>,
- ) -> datafusion::error::Result<Arc<dyn ExecutionPlan>> {
+ ) -> Result<Arc<dyn ExecutionPlan>> {
Ok(self)
}
fn execute(
&self,
_partition: usize,
_context: Arc<datafusion::execution::TaskContext>,
- ) ->
datafusion::error::Result<datafusion::execution::SendableRecordBatchStream> {
+ ) -> Result<datafusion::execution::SendableRecordBatchStream> {
let fut = self.provider.clone().scan();
- let stream = futures::stream::once(fut).try_flatten();
- let schema = self.provider.schema();
- Ok(Box::pin(RecordBatchStreamAdapter::new(schema, stream)))
+ let projection = self.projection.clone();
+
+ let stream =
+ futures::stream::once(fut)
+ .try_flatten()
+ .map(move |result| -> Result<_> {
+ let batch = result?;
+ match &projection {
+ Some(indices) => Ok(batch.project(indices)?),
+ None => Ok(batch),
+ }
+ });
Review Comment:
I did try to see if I could push this projection down further into the scan
so that we don't have to manually project them *after* reading all of the
columns, but it looks like iceberg-rust doesn't support this - the scan of the
tables happens [here
](https://github.com/apache/datafusion-iceberg/blob/main/crates/datafusion/src/table/metadata_table.rs#L95-L97)
which calls [this in
iceberg-rust](https://github.com/apache/iceberg-rust/blob/main/crates/iceberg/src/inspect/snapshots.rs#L82)
and that doesn't seem to take projections
Admittedly, I'm still trying to build a mental model of all of this and
might be missing something, so I can spend some more time trying to make this
work (or open PRs on iceberg-rust to add support for this)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]