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


##########
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:
   Any provider that isn't `LazyFileScanTaskProvider` gets the "planned 
eagerly" message here. A custom or future provider would see a misleading 
error. Would it be worth matching `EagerFileScanTaskProvider` explicitly and 
using a more generic message otherwise?



##########
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:
   The reader built from `table.reader_builder()` above gets replaced here by 
`with_reader`. That's harmless, but a one-line comment explaining why might 
help the next reader.



##########
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:
   The `now_or_never` below relies on `TaskContext::default()` leaving 
`eager_file_planning` off. If that default ever changed upstream, every decode 
would fail with the "waited on I/O" error. Could we build the context from a 
`SessionConfig` with that option set to `false` explicitly, so the assumption 
is visible right here?



##########
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:
   Not for this PR, but leaving the limit unset means each task can have up to 
the host's `available_parallelism()` files in flight, regardless of the 
executor's `vcores`. It matches the behaviour before the bump, so it's not a 
regression. It might be worth mentioning in follow-up 3 alongside 
`Table::with_runtime`.



##########
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:
   Since 56.0.0 includes #2752 and #2721, maybe this comment could say the git 
pin is now for #2940?



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