alexanderbianchi commented on code in PR #67: URL: https://github.com/apache/datafusion-iceberg/pull/67#discussion_r4577188656
########## crates/datafusion/src/read/eager.rs: ########## @@ -0,0 +1,247 @@ +// 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::sync::Arc; + +use datafusion::arrow::datatypes::SchemaRef; +use datafusion::common::tree_node::TreeNodeRecursion; +use datafusion::common::{Statistics, exec_err}; +use datafusion::datasource::source::DataSource; +use datafusion::error::Result; +use datafusion::execution::{SendableRecordBatchStream, TaskContext}; +use datafusion::physical_expr::projection::ProjectionExprs; +use datafusion::physical_expr::{EquivalenceProperties, Partitioning, PhysicalExpr}; +use datafusion::physical_plan::DisplayFormatType; +use datafusion::physical_plan::metrics::ExecutionPlanMetricsSet; +use futures::StreamExt; +use iceberg::arrow::ArrowReader; +use iceberg::scan::FileScanTask; + +use super::file_planning::PlannedFileScan; +use super::reader::ScanReader; + +/// An Iceberg scan whose complete file assignment is available before execution. +/// Reads already-selected file groups without retaining a table or discovery request. +/// Consumers can inspect and regroup these tasks, or reconstruct a source on another +/// process using a locally configured reader. +#[derive(Clone)] +pub struct EagerIcebergDataSource { + schema: SchemaRef, + fetch: Option<usize>, + reader: ScanReader, + files: Arc<PlannedFileScan>, + partitions: Arc<[Vec<usize>]>, +} +impl std::fmt::Debug for EagerIcebergDataSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("EagerIcebergDataSource") + .field("schema", &self.schema) + .field("fetch", &self.fetch) + .field("partitions", &self.partitions) + .finish_non_exhaustive() + } +} +impl EagerIcebergDataSource { + pub(crate) fn from_planned_files( + schema: SchemaRef, + files: PlannedFileScan, + groups: Vec<Vec<usize>>, + reader: ArrowReader, + fetch: Option<usize>, + ) -> Self { + Self { + schema, + fetch, + files: Arc::new(files), + partitions: groups.into(), + reader: ScanReader::new(reader), + } + } + + /// Construct a scan from already selected files grouped by local output partition. + /// Preserves group order without discovering, pruning, or assigning files. + /// The caller supplies a process-local reader configured for these files. Reader + /// clones share its delete cache across partitions; regrouping preserves its + /// settings, including file concurrency. The schema must match the tasks' projection. + /// Descriptors are charged to `context`'s memory pool; statistics are unknown. + /// + /// # Errors + /// Returns an error if there are no partition groups or memory reservation fails. + /// Empty groups are valid, including for an empty scan. + pub fn from_file_groups( Review Comment: Removing it, using `with_planned_files` -- 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]
