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


##########
crates/datafusion/src/read/file_scan_task_provider/provider.rs:
##########
@@ -0,0 +1,66 @@
+// 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::any::Any;
+use std::fmt::{Debug, Formatter};
+use std::sync::Arc;
+
+use datafusion::common::Result;
+use datafusion::execution::TaskContext;
+use datafusion::physical_plan::Partitioning;
+use iceberg::table::Table;
+
+/// Supplies the file tasks an 
[`IcebergDataSource`](crate::read::IcebergDataSource)
+/// reads, split into output partitions.
+///
+/// The data source owns reading, limits and metrics; implementations only
+/// decide which files each partition reads and when they are discovered.
+/// Implementations are `Any`, so consumers such as codecs can downcast a
+/// source's 
[`file_scan_task_provider`](crate::read::IcebergDataSource::file_scan_task_provider)
+/// to a concrete type:
+///
+/// ```
+/// # use std::any::Any;
+/// # use iceberg_datafusion::read::{IcebergDataSource, 
EagerFileScanTaskProvider};
+/// fn planned_files(source: &IcebergDataSource) -> 
Option<&EagerFileScanTaskProvider> {
+///     (source.file_scan_task_provider() as &dyn 
Any).downcast_ref::<EagerFileScanTaskProvider>()
+/// }
+/// ```
+pub trait FileScanTaskProvider: Any + Debug + Send + Sync {

Review Comment:
   Yes that was the idea in 
https://github.com/apache/datafusion-iceberg/pull/107. Similar API, I like 
yours returning the partitioning instead of the count more. I don't know I'd 
considered it also a solution for the eager path (or if I did, I had forgotten 
😆)
   ```rust
   pub trait FileScanTaskSource: Clone + Debug + Send + Sync + 'static {
       /// Number of local output partitions, not a worker or distributed task 
count.
       fn partition_count(&self) -> usize;
   
       /// Opens a partition's stream during execution, without collecting it.
       ///
       /// Discovery can start here or when the stream is polled. Calls on one
       /// instance may coordinate discovery; a repeated claim of the same 
partition
       /// may be rejected. Implementations must not block waiting for tasks 
here.
       fn tasks(
           &self,
           partition: usize,
           context: Arc<TaskContext>,
       ) -> Result<FileScanTaskStream>;
   
       /// Appends task-source details to the data source's explain output.
       fn fmt_as(&self, _f: &mut Formatter<'_>) -> std::fmt::Result {
           Ok(())
       }
   }
   ```



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