NoahKusaba commented on code in PR #2941:
URL: 
https://github.com/apache/datafusion-ballista/pull/2941#discussion_r4697233682


##########
integrations/iceberg/src/physical_codec.rs:
##########
@@ -96,9 +111,18 @@ impl PhysicalExtensionCodec for IcebergPhysicalCodec {
         else {
             return not_impl_err!("{} isn't an Iceberg scan", node.name());
         };
+        // Executors discover the scan's files themselves, from the table.
+        let tasks = source.file_scan_task_provider() as &dyn Any;
+        let Some(tasks) = tasks.downcast_ref::<LazyFileScanTaskProvider>() 
else {

Review Comment:
   Good catch. Done: `EagerFileScanTaskProvider` is matched explicitly, and 
other providers get a generic error, with a test.



##########
integrations/iceberg/src/physical_codec.rs:
##########
@@ -72,16 +77,26 @@ impl PhysicalExtensionCodec for IcebergPhysicalCodec {
         &self,
         buf: &[u8],
         _inputs: &[Arc<dyn ExecutionPlan>],
-        _ctx: &TaskContext,
+        ctx: &TaskContext,
         _proto_converter: &dyn PhysicalProtoConverterExtension,
     ) -> Result<Arc<dyn ExecutionPlan>> {
         let scan: ScanWire = wire::decode(buf)?;
-        let source = IcebergDataSource::builder(scan.table.load()?, 
scan.schema)
-            .with_snapshot_id(scan.snapshot_id)
-            .with_predicate(scan.predicate)
-            .with_fetch(scan.fetch)
-            .build()?;
-        Ok(DataSourceExec::from_data_source(source))
+        let table = scan.table.load()?;
+        // A default context leaves eager file planning off, so the provider
+        // discovers files when the scan runs, and building it awaits nothing.
+        let tasks = FileScanTaskProviderBuilder::new(
+            Arc::new(TaskContext::default()),

Review Comment:
   Done: decode now sets `eager_file_planning = false` explicitly.



##########
integrations/iceberg/src/catalog.rs:
##########
@@ -202,3 +211,35 @@ impl TableProvider for PinnedTable {
         not_impl_err!("INSERT INTO an Iceberg table isn't supported on 
Ballista yet")
     }
 }
+
+/// Builds the plan that reads `tasks` from `table`.
+///
+/// The reader takes its batch size and page index use from `config`, like
+/// iceberg-datafusion's default reader, but leaves the number of data files
+/// read at once to Iceberg, one per CPU. iceberg-datafusion reads one file at 
a
+/// time, expecting each output partition to read in parallel, but a lazy scan
+/// has one partition, so its files would be read one after another.
+pub(crate) fn scan_exec(
+    config: &SessionConfig,
+    table: &Table,
+    schema: SchemaRef,
+    tasks: Arc<dyn FileScanTaskProvider>,
+    fetch: Option<usize>,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    let options = ArrowReaderOptions::builder()
+        .with_batch_size(config.batch_size())
+        
.with_row_selection_enabled(config.options().execution.parquet.enable_page_index)
+        .build();
+    let reader = table.reader_builder().with_options(options).build();
+    let source = IcebergDataSource::builder(
+        config,
+        schema,
+        table.file_io().clone(),
+        table.reader_builder(),
+        tasks,
+    )
+    .with_reader(reader)

Review Comment:
   Done, added a comment.



##########
integrations/iceberg/src/catalog.rs:
##########
@@ -202,3 +211,35 @@ impl TableProvider for PinnedTable {
         not_impl_err!("INSERT INTO an Iceberg table isn't supported on 
Ballista yet")
     }
 }
+
+/// Builds the plan that reads `tasks` from `table`.
+///
+/// The reader takes its batch size and page index use from `config`, like
+/// iceberg-datafusion's default reader, but leaves the number of data files
+/// read at once to Iceberg, one per CPU. iceberg-datafusion reads one file at 
a
+/// time, expecting each output partition to read in parallel, but a lazy scan
+/// has one partition, so its files would be read one after another.
+pub(crate) fn scan_exec(
+    config: &SessionConfig,
+    table: &Table,
+    schema: SchemaRef,
+    tasks: Arc<dyn FileScanTaskProvider>,
+    fetch: Option<usize>,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    let options = ArrowReaderOptions::builder()

Review Comment:
   Agreed, added to follow-up 3.



##########
integrations/iceberg/Cargo.toml:
##########
@@ -41,38 +41,37 @@ publish = false
 ignored = ["arrow-schema"]
 
 [dependencies]
-arrow-schema = { version = "59.2.0", features = ["serde"] }
+arrow-schema = { version = "60.2.0", features = ["serde"] }
 async-trait = "0.1"
 # A commit on main with ComposedLogicalExtensionCodec (#2752) and the
 # partition-sliceable resolver (#2721), not the crates in this repo, so a
-# change to Ballista doesn't break this build. It is the last commit before
-# Ballista moved to DataFusion 56, which iceberg-datafusion doesn't support
-# yet. Move to crates.io once a release includes both.
-ballista-core = { git = "https://github.com/apache/datafusion-ballista";, rev = 
"2f4938ef05c38f8e68f944d6aed22f2f5714a9ed", version = "55.0.0" }
-ballista-executor = { git = "https://github.com/apache/datafusion-ballista";, 
rev = "2f4938ef05c38f8e68f944d6aed22f2f5714a9ed", version = "55.0.0", 
default-features = false, optional = true }
-ballista-scheduler = { git = "https://github.com/apache/datafusion-ballista";, 
rev = "2f4938ef05c38f8e68f944d6aed22f2f5714a9ed", version = "55.0.0", 
default-features = false, optional = true }
-datafusion = "55"
-datafusion-proto = "55"
+# change to Ballista doesn't break this build. Move to crates.io once a

Review Comment:
   Done: 56.0.0-rc1 includes everything this crate uses, so the comment now 
says the pin is waiting for 56.0.0 to be published. #2940 isn't merged yet, so 
follow-up 1 will need its own pin.



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