alexanderbianchi commented on code in PR #109:
URL: 
https://github.com/apache/datafusion-iceberg/pull/109#discussion_r4603040252


##########
crates/datafusion/src/read/file_scan_task_provider/lazy.rs:
##########
@@ -0,0 +1,80 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+use std::fmt::Formatter;
+use std::sync::Arc;
+
+use datafusion::common::Result;
+use datafusion::physical_plan::Partitioning;
+use futures::TryStreamExt;
+use iceberg::expr::Predicate;
+
+use super::provider::{FileScanTaskProvider, FileScanTaskProviderContext};
+use crate::to_datafusion_error;
+
+/// Discovers files while executing, in a single partition: the files of a
+/// snapshot that may match a predicate.
+#[derive(Debug, Clone)]
+pub struct LazyFileScanTaskProvider {

Review Comment:
   I think we might be able to push this even further
    ```rust
      struct LazyFileScanTaskProvider {
          table: Table,
          snapshot_id: Option<i64>,
          projection: Vec<String>,
          predicate: Option<Predicate>,
      }
    ```
   and
    ```rust
      struct EagerFileScanTaskProvider {
          groups: Vec<Vec<FileScanTask>>,
      }
    ```
   Such that we can remove some of the logic from the data source, and it's 
builder.
   ```rust
      let discovery = Arc::new(LazyFileScanTaskProvider {
          table,
          snapshot_id,
          projection,
          predicate,
      });
   
      let provider: Arc<dyn FileScanTaskProvider> =
          if iceberg_config.execution.eager_file_planning {
              Arc::new(
                  EagerFileScanTaskProvider::plan(discovery, context).await?,
              )
          } else {
              discovery
          };
   
      let source = IcebergDataSourceBuilder::new(schema, file_io, reader)
          .with_file_scan_task_provider(provider)
          .with_fetch(limit)
          .build()?;
   ```
   Something like this, isolates the async out of the data source builder and 
removes the Table from the data source.



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

Reply via email to