Skip to content

feat(datafusion): add IcebergCatalogConfig and propagate it into scan/write/commit nodes - #2727

Closed
NoahKusaba wants to merge 18 commits into
apache:mainfrom
NoahKusaba:feature/datafusion-catalog-config
Closed

feat(datafusion): add IcebergCatalogConfig and propagate it into scan/write/commit nodes#2727
NoahKusaba wants to merge 18 commits into
apache:mainfrom
NoahKusaba:feature/datafusion-catalog-config

Conversation

@NoahKusaba

@NoahKusaba NoahKusaba commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Add Enhancements to datafusion-iceberg crate, for future ballista-iceberg integration (which will be put another repo)
#2613

What changes are included in this PR?

Adds a new passable parameter
impl IcebergCatalogConfig { pub fn new( r#type: impl Into<String>, name: impl Into<String>, props: HashMap<String, String>, ) -> Self { Self { r#type: r#type.into(), name: name.into(), props, } } }

to both
IcebergCommitExec and IcebergWriteExec

This allows optional serializable catalog/storage config, populated when this node is built through a config-backed provider, so it can be reconstructed on remote node by a distributed engine.

Also adds an optional Snapshot ID parameter to pin scans

Are these changes tested?

Yes added unit tests verifying:

  • test_with_snapshot_id_pins_scan: verifies IcebergTableScan returns set snapshot id

  • test_schema_provider_with_config_propagates_to_tables:
    This tests that when you pass optional parameter "IcebergCatalogConfig" to "IcebergSchemaProvider", it will be handed back by every "IcebergTableProvider":
    assert!(iceberg.config().is_some(), ...); // with config → present assert!(iceberg.config().is_none()); // without config → absent (to ensure old behavior stays the same)

@NoahKusaba
NoahKusaba marked this pull request as draft June 28, 2026 01:46
@NoahKusaba NoahKusaba changed the title feat(datafusion) feat(datafusion): Serializable Codec for Distributed Engines Jun 28, 2026
@NoahKusaba
NoahKusaba marked this pull request as ready for review June 28, 2026 18:30
NoahKusaba and others added 11 commits July 11, 2026 14:38
## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->

- Partially closes apache#2607

## What changes are included in this PR?

<!--
Provide a summary of the modifications in this PR. List the main changes
such as new features, bug fixes, refactoring, or any other updates.
-->

- If a projection includes `_spec_id`, which is a constant like the
`_file` metadata column for all rows, add it to
`RecordBatchTransformerBuilder`


## Are these changes tested?

<!--
Specify what test covers (unit test, integration test, etc.).

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

 - Yes, unit tests.
 - Iceberg Spark: apache/datafusion-comet#4752
 
Sample plan

```shell
== Physical Plan ==
AdaptiveSparkPlan isFinalPlan=false
+- CometSort [id#1247L, data#1248, _spec_id#1249], [id#1247L ASC NULLS FIRST]
   +- CometExchange rangepartitioning(id#1247L ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, CometNativeShuffle, [plan_id=3533]
      +- CometFilter [id#1247L, data#1248, _spec_id#1249], (id#1247L >= 10)
         +- CometIcebergNativeScan [id#1247L, data#1248, _spec_id#1249], /var/folders/d2/b93h6k7174ddqxltrxgb51040000gn/T/iceberg_warehouse16657344237870771906/iceberg_data/default/table/metadata/00004-70b616c5-1bbe-4e1d-bdd6-e9ac4910674a.metadata.json, testrest.default.table (branch=null) [filters=id IS NOT NULL, id >= 10, groupedBy=], 1
```
## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->

- Working towards apache#2034

We're currently not able to decrypt PME encrypted files, all that's
needed for this PR is to wire through the key_metadata from the manifest
entries into the scan tasks and then configure the parquet reader with
the correct encryption key and aad.

It's important to note that no encryption manager is needed here since
the key_metadata on the manifest files contain the plaintext keys.

## What changes are included in this PR?

<!--
Provide a summary of the modifications in this PR. List the main changes
such as new features, bug fixes, refactoring, or any other updates.
-->

## Are these changes tested?

Tests follow the pattern on manually writing an encrypted parquet file
using the raw arrow-rs writer and then using the FileScanTask and
iceberg reader to read that tmp file.

I looked at using the [parquet testing
repo](https://github.com/apache/parquet-testing) but the encrypted files
there all use column based encryption which isn't supported by the spec.
I'll separately track adding some files there that we can use here but
the testing strategy here is consistent with how Java does things so I
think this should be sufficient for us to continue.
<!--
Specify what test covers (unit test, integration test, etc.).

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
## Which issue does this PR close?
Variant Support.
Arrow value support is currently missing as I am unsure how we want to
extend `Literal`

## What changes are included in this PR?
### Core: Variant Type
- `crates/iceberg/src/spec/datatypes.rs` — new `Variant` type
- `crates/iceberg/src/spec/values/literal.rs` — `Variant` literal value
- `crates/iceberg/src/spec/schema/` — visitor, index, pruning, mod, id
reassigner all handle `Variant`
- `crates/iceberg/src/spec/table_metadata.rs` — metadata support

### Avro
- `crates/iceberg/src/avro/schema.rs` — read/write `Variant` in Avro

### Arrow
- `crates/iceberg/src/arrow/schema.rs` — map `Variant` to Arrow type
- `crates/iceberg/src/arrow/reader.rs` — read `Variant` from Arrow
- `crates/iceberg/src/arrow/value.rs` — Arrow value conversion
- Minor fixes in `caching_delete_file_loader.rs` and
`nan_val_cnt_visitor.rs`

### Parquet
- `crates/iceberg/src/writer/file_writer/parquet_writer.rs` — write
`Variant` columns

### Tests & Dev
- `crates/integration_tests/tests/read_variant.rs` — new integration
test for reading Variant data
- `dev/spark/provision.py` — Spark provisioning to generate Variant test
data


## Are these changes tested?
Sure! Even integration tested :)

---------

Co-authored-by: Shawn Chang <yxchang@amazon.com>
…teral JSON codec (apache#2832)

## Which issue does this PR close?
We don't have an issue for this. Deserializing Timestamp NS default
values failed.

## What changes are included in this PR?

`try_into_json` serialized TimestampNs/TimestamptzNs but `try_from_json`
had no matching arms, so a nanosecond-timestamp single value (e.g. a
column default) failed to deserialize (fell to the DataInvalid
catch-all). Add the read arms
mirroring the microsecond ones, plus `datetime_to_nanoseconds` /
`datetimetz_to_nanoseconds` helpers. Also adds json_timestamp_ns /
json_timestamptz_ns tests.

## Are these changes tested?

Yes
@NoahKusaba
NoahKusaba force-pushed the feature/datafusion-catalog-config branch from 0ea1ca9 to 03f5378 Compare July 16, 2026 20:46
@NoahKusaba NoahKusaba changed the title feat(datafusion): Serializable Codec for Distributed Engines feat(datafusion): add IcebergCatalogConfig and propagate it into scan/write/commit nodes Jul 21, 2026
@NoahKusaba

Copy link
Copy Markdown
Contributor Author

I'll split this up into the snapshot id Pr and the catalogConfig PR, to make it easier on maintainers.

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.

4 participants