Skip to content

Conversation

@mbutrovich
Copy link
Contributor

@mbutrovich mbutrovich commented Oct 6, 2025

This PR introduces a new approach for integrating Apache Iceberg with Comet using iceberg-rust, enabling fully-native Iceberg table scans without requiring changes to upstream Iceberg Java code.

Rationale for this change

I was inspired by @RussellSpitzer's recent talk and wanted to revisit the abstraction layer at which Comet integrates with Iceberg.

Our current iceberg_compat approach requires code changes in Iceberg Java to integrate with Parquet reader instantiation, creating a tight coupling between Comet and Iceberg. This PR instead works at the FileScanTask layer after Iceberg's planning phase is complete. This enables fully-native Iceberg scans (similar to our native_datafusion scans) without any changes in upstream Iceberg Java code.

All catalog access and planning continues to happen through Spark's Iceberg integration (unchanged), but file reading is delegated to iceberg-rust, which provides better parallelism and integrates naturally with Comet's native execution engine.

What changes are included in this PR?

This implementation follows a similar pattern to CometNativeScanExec for regular Parquet files, but extracts and serializes Iceberg's FileScanTask objects:

Scala/JVM Side:

  • New CometIcebergNativeScanExec operator that replaces Spark's Iceberg BatchScanExec
  • Uses reflection to extract FileScanTask objects from Iceberg's planning output
  • Serializes tasks and catalog properties to protobuf for native execution

Native/Rust Side:

  • New IcebergScanExec operator that consumes serialized FileScanTask objects
  • Uses iceberg-rust's FileIO and ArrowReader to read data files
  • Leverages catalog properties to configure FileIO (credentials, regions, etc.)

How are these changes tested?

  • New CometIcebergNativeSuite with basic scenarios, but also a number of challenging situations from the Iceberg Java test suite
  • New CometFuzzIcebergSuite that we can adapt to Iceberg-specific logic
  • New IcebergReadFromS3Suite to test passing basic S3 credentials
  • Tested locally with Iceberg 1.5, 1.7, 1.10, CI tests 1.8.1 and 1.9.1

Benefits over iceberg_compat

  1. No upstream changes needed - No references to Comet needed in Iceberg Java anymore
  2. Better parallelism - File reading happens at the same granularity as native_datafusion, not constrained by Iceberg Java's reader design
  3. Simplified runtime - No separate DataFusion runtime; scans run in the same context as other operators
  4. Better testing for iceberg-rust - I’ve already upstreamed several fixes for iceberg-rust’s ArrowReader
  5. Multi-version support - Reflection approach is version agnostic

Current Limitations & Open Questions

Related Work

Slides from the 10/9/25 Iceberg-Rust community call: iceberg-rust.pdf

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 74.26667% with 193 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.33%. Comparing base (f09f8af) to head (d88c911).
⚠️ Report is 670 commits behind head on main.

Files with missing lines Patch % Lines
...ain/scala/org/apache/comet/serde/icebergScan.scala 76.67% 76 Missing and 25 partials ⚠️
...n/scala/org/apache/comet/rules/CometScanRule.scala 61.72% 38 Missing and 24 partials ⚠️
...e/spark/sql/comet/CometIcebergNativeScanExec.scala 82.30% 4 Missing and 19 partials ⚠️
...n/scala/org/apache/comet/rules/CometExecRule.scala 54.54% 3 Missing and 2 partials ⚠️
...la/org/apache/comet/objectstore/NativeConfig.scala 0.00% 1 Missing ⚠️
.../scala/org/apache/comet/serde/QueryPlanSerde.scala 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2528      +/-   ##
============================================
+ Coverage     56.12%   60.33%   +4.20%     
- Complexity      976     1498     +522     
============================================
  Files           119      149      +30     
  Lines         11743    14553    +2810     
  Branches       2251     2496     +245     
============================================
+ Hits           6591     8780    +2189     
- Misses         4012     4482     +470     
- Partials       1140     1291     +151     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@comphead
Copy link
Contributor

comphead commented Oct 6, 2025

It is promising!

@mbutrovich mbutrovich changed the title feat: Iceberg scan based serializing FileScanTasks to iceberg-rust feat: [iceberg] Scan based serializing FileScanTasks to iceberg-rust Oct 6, 2025
@mbutrovich mbutrovich changed the title feat: [iceberg] Scan based serializing FileScanTasks to iceberg-rust feat: Iceberg scan based serializing FileScanTasks to iceberg-rust Oct 6, 2025
# Conflicts:
#	native/Cargo.lock
#	spark/src/main/scala/org/apache/comet/rules/CometScanRule.scala
…eberg version back to 1.8.1 after hitting known segfaults with old versions.
liurenjie1024 pushed a commit to apache/iceberg-rust that referenced this pull request Oct 16, 2025
## Which issue does this PR close?


- Part of #1749.

## What changes are included in this PR?

- Change `ArrowReaderBuilder::new` to be `pub` instead of `pub(crate)`.

## Are these changes tested?

- No new tests for this. Currently being used in DataFusion Comet:
apache/datafusion-comet#2528
# Conflicts:
#	docs/source/user-guide/latest/configs.md
#	native/Cargo.lock
#	native/Cargo.toml
#	native/core/Cargo.toml
@mbutrovich mbutrovich changed the title feat: [iceberg] Native scan based serializing FileScanTasks to iceberg-rust feat: [iceberg] Native scan by serializing FileScanTasks to iceberg-rust Nov 3, 2025
@mbutrovich mbutrovich marked this pull request as ready for review November 3, 2025 20:17
@mbutrovich
Copy link
Contributor Author

CI runs these already for PRs tagged [iceberg] so people can see that it's green there, but for posterity here is Iceberg's Spark tests...
Screenshot 2025-11-03 at 9 09 52 AM
and Spark extensions tests...
Screenshot 2025-11-03 at 9 09 43 AM

liurenjie1024 pushed a commit to apache/iceberg-rust that referenced this pull request Nov 5, 2025
…ame FileScanTask (#1778)

## What issue does this PR close?

Partially address #1749.

## Rationale for this change

This PR fixes a bug in delete file loading when a `FileScanTask`
contains both positional and equality delete files. We hit this when
running Iceberg Java test suite via Comet in
apache/datafusion-comet#2528. The tests that
failed were
```
TestSparkExecutorCache > testMergeOnReadUpdate()
TestSparkExecutorCache > testMergeOnReadMerge()
TestSparkExecutorCache > testMergeOnReadDelete()
```

**The Bug:**
The condition in `try_start_eq_del_load` (delete_filter.rs:71-73) was
inverted. It returned `None` when the equality delete file was not in
the cache, causing the loader to skip loading it. When
`build_equality_delete_predicate` was later called, it would fail with
"Missing predicate for equality delete file".

## What changes are included in this PR?

**The Fix:**
- Inverted the condition so it returns `None` when the file is already
in the cache (being loaded or loaded), preventing duplicate work across
concurrent tasks
- When the file is not in the cache, mark it as Loading and proceed with
loading

**Additional Changes:**
- Added test case `test_load_deletes_with_mixed_types` that reproduces
the bug scenario
 
## Are these changes tested?

Yes, this PR includes a new unit test
`test_load_deletes_with_mixed_types` that:
- Creates a `FileScanTask` with both a positional delete file and an
equality delete file
- Verifies that `load_deletes` successfully processes both types
- Verifies that `build_equality_delete_predicate` succeeds without the
"Missing predicate" error
- We hit this when running Iceberg Java test suite via Comet in
apache/datafusion-comet#2528. I also confirmed
that it fixes the tests in Iceberg Java's suite.

The test would fail before this fix and passes after.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants