Repository navigation
feat: native Iceberg reads of Variant columns - #7575
mbutrovich wants to merge 47 commits into
Conversation
…store 0.14 Point the DataFusion dependencies at a git revision of apache/datafusion main (350ca76505c9513d16e7dd9910bcd9bde2c911ed), which is on arrow/parquet 60.0.0 and object_store 0.14.2. Bump arrow, parquet, object_store and object_store_opendal (0.59.0, the first release on object_store 0.14) to match. iceberg-rust main is still on arrow 59, and the head of apache/iceberg-rust#3257 (Arrow 60) is 42 commits behind the main revision Comet builds against. Pin iceberg and iceberg-storage-opendal to a branch on the andygrove/iceberg-rust fork that merges apache/iceberg-rust main (1f3bc34) into that PR. Source changes for the new APIs: - Arrow 60 makes the FFI_ArrowArrayStream callbacks private, so the decimal-realignment test builds the import with from_ffi_and_data_type. - Parquet 60 moves the page index behind ParquetMetaData::page_index(), a PageIndexProvider with per-row-group access. - DataFusion's coerce_int96 and coerce_int96_tz are typed (DFTimeUnit, ConfigTimeZone) instead of strings. - OffsetBuffer::first/last return values and schema metadata is arrow's Metadata type. - HashJoinExec::with_dynamic_filter_expr, SortExec::with_dynamic_filter_expr, ExecutionPlan::with_preserve_order and ParquetAccessPlan::into_overall_row_selection are deprecated; allow them where Comet still needs them. - Arrow 60's MapBuilder names map children key/value by default, so make_map_c names them keys/values explicitly to keep exercising non-canonical names. - datafusion-spark's SparkXxhash64 now ignores the hidden children of a NULL struct and keeps the running hash for nested dictionaries (apache/datafusion #25774, #25813), so the tests that pinned those differences assert equality.
…ore its test Parquet 60 writes NaN min/max statistics for a float or double column chunk holding only NaN, and iceberg-rust copies them into the manifest bounds, where iceberg-java records none. Ignore the parity test that catches it, list the issue under the Iceberg known issues and add it to the 1.3.0 upgrade guide. It is tracked in apache#7242.
Point the DataFusion dependencies at the head of apache/datafusion branch-56 (1635ed94742c1c060852bc34dc6ebb2302241c7b), cut for the 56.0.0 release. It is 116 commits past the previous main revision and moves arrow/parquet to 60.1.0. - Bump arrow, arrow-data, arrow-select and parquet to 60.1.0. - Bump parking_lot to 0.13, which DataFusion's LazyBatchGenerator API now uses. - Rename ArrowArrayStreamReader to RecordBatchStreamReader (deprecated alias). - Use FixedSizeListArray::value_offset_at instead of the deprecated value_offset. - Arrow 60.1.0 encodes the IPC frame in the RSS bounded-buffer test 2048 bytes smaller, so the test measures the frame size instead of hard-coding it.
DataFusion 56 coerces nested BINARY file fields to Utf8 before the parquet reader, which skips UTF-8 validation for unannotated BINARY columns, so the native scan panics in debug builds instead of decoding to U+FFFD. Ignore the Rust and JVM tests from apache#7106 until apache/datafusion#27065 is fixed (apache#7469).
…d setters DataFusion 56 deprecates HashJoinExec::with_dynamic_filter_expr and SortExec::with_dynamic_filter_expr with no replacement. Comet does not need them: - A SortExec with a fetch creates its own TopK filter, so the runtime TopK takes that filter from dynamic_expressions_produced() and hands it to the Parquet reader below the sort, instead of installing one from outside. - For joins, Comet reports to HashJoinExec::handle_child_pushdown_result what DataFusion's FilterPushdown rule would: the probe-side self filter was pushed down. The join then installs the filter itself after finding Comet's consumer in its probe subtree.
DataFusion 56 renames OrderedFinalAggregateStream to ClusteredFinalAggregateStream (apache/datafusion#24697), and the memory consumer with it. The fair pool's exemption for that consumer and the spill replay pool's final-aggregate check match it by name, so on DataFusion 56 neither matched anymore. Match the new name, and update the tests, docs and comments that use the old one.
# Conflicts: # native/native-executors/Cargo.lock
DataFusion 56 includes apache/datafusion#25383, which leaves room for a final aggregate to read its spill files back, so SpillReplayPool is no longer needed. It is also now harmful: #25383 holds replay headroom on a sibling reservation while the spill merge picks its files, so the pool took every refused read-buffer request for a replay and granted it. The merge then opened every spill file and starved the next aggregate, which failed the apache#6880 PartialMerge test with a 2 MiB pool. The apache#6254 and apache#6857 read-back tests, which the pool was added for, pass without it. The sort-merge join apache#6880 test now uses an 8 MiB pool, because with DataFusion 56 its PartialMerge fits in 12 MiB or more without spilling. Closes apache#6583.
Move the andygrove/iceberg-rust fork pin to apache/iceberg-rust#3257 with apache/iceberg-rust main at 46e51d8 merged in. Main now includes apache/iceberg-rust#3539, which skips NaN min and max statistics when aggregating Parquet column bounds, so the native writer no longer records NaN manifest bounds for all-NaN float and double columns on Parquet 60. This fixes the Iceberg TestAggregatePushDown testNaN and testAllNaN failures, re-enables the NaN manifest metrics test, and drops the known issue from the docs. Closes apache#7242.
…native-executors job Move the DataFusion pin from 1635ed94742c to 964f925bd02 (the head of branch-56 on 2026-11-09), which adds the 56.0.0 release preparation and a set of backported fixes. Regenerate native/Cargo.lock and contrib/delta/native/Cargo.lock. native/native-executors builds Comet's core by path together with a Ballista revision that pins DataFusion 1635ed94742c, so it can no longer build until Ballista moves. Turn its CI job off until the two pins agree again. Its Cargo.toml and Cargo.lock are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts: keep the spill replay pool removed and apply DataFusion 56's ClusteredFinalAggregateStream name to main's reworked fair pool (apache#7630). Keep the andygrove/iceberg-rust revision, which contains main's de0a6ac, and add main's opendal-hdfs-native feature to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge brought in tests written against DataFusion 55.2: - Field::with_metadata takes impl Into<Metadata> in Arrow 60, so pass the array of pairs directly. - AggregateExec::input_order_mode is now group_clustering_mode, and a fully sorted input is GroupClusteringMode::Full. - Two apache#7630 fair pool tests set the task share to exactly the peak of the lowest operator. DataFusion 56 has each aggregate reserve its initial table when the plan starts (apache/datafusion#25900), so the aggregates above hold a few KiB while it runs, and the sort or first aggregate spilled. Add what the aggregates above reserve over empty input to the share. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…job back on Ballista main (a882d9d8) is on DataFusion's 56.0.0-rc1 tag, the same tag as native/Cargo.toml, so native/native-executors builds again. Pin it there, with DataFusion at that tag, and restore the job's condition. Ballista's rest-api feature now enables tracing itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…utors job off DataFusion 56.0.0 is tagged (7e7ae72a8) but not yet published to crates.io, so pin its git tag instead of 56.0.0-rc1. Ballista main is still on the rc1 tag, so two copies of DataFusion would be in the native-executors build; turn its CI job off again until Ballista is on the 56.0.0 tag.
…lReplayPool In DataFusion 56 the replay reserves its empty table before the merge picks its spill files, so the merge's headroom requests were granted past the pool limit. A refusal now counts as the replay's only when the consumer's other reservations hold more than its first growth from zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… as unable to spill Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eruns EnsureRequirements Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # native/Cargo.lock # native/Cargo.toml
…t-read # Conflicts: # native/core/src/execution/operators/iceberg_scan.rs
… null checks out of the residual
comphead
left a comment
There was a problem hiding this comment.
The gate change reads well. iceberg-rust at 1d4c20a unshreds every Variant in its record batch transformer, and empty or metadata-only projections install the row-number source so they read no data columns, so the COUNT(*) and _file cases hold. Required Checks is red because Preflight fails on the unregistered suite below, so no build or test job has run on this head yet. The three "TODO before merge" items in the description are still open, and the dependency move overlaps my draft #7798, which edits the same Cargo.toml and Cargo.lock lines with an older iceberg-rust pin. I will rebase my draft onto whichever lands first.
| import org.apache.spark.sql.types.VariantType | ||
|
|
||
| class CometIcebergNativeScanVariantSuite extends AnyFunSuite with Matchers { | ||
|
|
There was a problem hiding this comment.
This suite is not listed in .github/workflows/pr_build_linux.yml or pr_build_macos.yml. dev/ci/check-suites.py exits with Suite not found in workflow for it, which I think is the Preflight failure, and Preflight gates every build job, so none of the new tests have run in CI. Adding it next to org.apache.comet.serde.operator.CometIcebergNativeScanSuite in both workflows should fix it. I read the script but did not run it.
There was a problem hiding this comment.
Thanks, I added it next to CometIcebergNativeScanSuite in both workflows.
| files fall back to Spark. Native Iceberg scans read Variant columns at any depth, shredded or not, | ||
| except in tables with equality deletes keyed on a Variant column. Spark also handles columnar-to-row |
There was a problem hiding this comment.
One more case fails now instead of falling back. When a data file has no Parquet field ids and the table has no name mapping, iceberg-rust uses position-based projection and returns FeatureUnsupported: Reading variant columns from Parquet files without field ids is not supported yet for any projected Variant (crates/iceberg/src/arrow/reader/projection.rs lines 112-123 at 1d4c20a). Iceberg Java reads such files with ParquetSchemaUtil.addFallbackIds. The gate cannot see this at planning time, so the query fails at runtime. Iceberg's add_files procedure sets a name mapping, so this mostly affects files imported by other tools. Could this page and iceberg.md mention it?
There was a problem hiding this comment.
Good catch. Both pages now say that a query reading a Variant column from such a file fails in the native scan with that error, and why the planner can't fall back. The iceberg.md note is under "Reads that differ from Spark", next to the existing entry for files with neither field ids nor a name mapping. I filed apache/iceberg-rust#3808 for reading these files, and both pages link it.
| # Not optional: the location-scoped Iceberg storage recognizes opendal's permission errors, and | ||
| # iceberg-storage-opendal builds the crate anyway. `hdfs-opendal` adds its HDFS service. | ||
| opendal = { version = "0.58.1" } | ||
| opendal = { version = "0.59.5" } |
There was a problem hiding this comment.
The coupling the description explains belongs in this comment too. iceberg_location_scoped.rs matches permission errors with downcast_ref::<opendal::Error>(), which matches only errors from the opendal version that iceberg-storage-opendal uses. Its tests build opendal::Error from this crate's own opendal, so a version skew would still build and pass while denied reads stop being recognized. Something like "Keep this on the opendal version that iceberg-storage-opendal uses" would stop the next pin bump from splitting them.
There was a problem hiding this comment.
Added that comment, including why the tests would not catch a split.
| s"SELECT id FROM $table WHERE try_variant_get(data, '$$.num', 'int') > 30 ORDER BY id") | ||
| checkIcebergNativeScan(s"SELECT id, to_json(data) FROM $table ORDER BY id") |
There was a problem hiding this comment.
No test reads a Variant column that schema evolution added after some files were written. In that case iceberg-rust fills the missing column with new_null_array of struct<metadata, value> (its test_read_variant_missing_from_file), and Comet then sends that through normalize_variant_array. An ALTER TABLE ... ADD COLUMN v VARIANT after the first insert, with a second insert and a read of both files, would cover it at the top level and inside a struct. I did not run this.
There was a problem hiding this comment.
Added variant columns added after files were written read natively. It writes a file, adds a top-level data VARIANT and a nested.data VARIANT, writes a second file, and checks native reads of both files against Spark. A read of nested.data without nested.label falls back on the existing check for structs whose projected fields were all added by schema evolution, so the test checks that fallback too.
…nt serde suite, document field-id limitation
…dual null-check comment
Iceberg 1.10.0's reader drops every row group for a pushed-down IS NOT NULL on a Variant column (apache/iceberg#14081) and throws an NPE on an unprojected Variant (apache/iceberg#14261). Both fixes were backported to 1.10.1.
Which issue does this PR close?
Part of #4295.
This PR is stacked on #7249 (DataFusion 56 and arrow 60) and merges after it. Until then, the diff includes #7249's changes. This PR's own changes are in
CometScanRule,CometExecRule,CometIcebergNativeScan, their tests, the Variant notes indatatypes.mdandiceberg.md, and the iceberg-rust, opendal, and object_store_opendal versions innative/Cargo.tomlandnative/core/Cargo.toml.Rationale for this change
iceberg-rust reads unshredded Variant columns since apache/iceberg-rust#2880 and shredded ones since apache/iceberg-rust#3683. Both are on iceberg-rust
main, which is on arrow 60, so Comet needs #7249 to use them.What changes are included in this PR?
icebergandiceberg-storage-opendalmove to apache/iceberg-rust@1d4c20a, the feat(arrow): read shredded variant columns iceberg-rust#3683 merge commit.opendalmoves to 0.59.5 andobject_store_opendalto 0.60.5, its first release on opendal 0.59. The location-scoped Iceberg storage recognizes permission errors by downcasting toopendal::Error, which only matches errors from the same opendal version that iceberg-storage-opendal uses.CometScanRule: allow Variant at any depth in Iceberg scans, including empty projections such asCOUNT(*)and metadata-only ones such asSELECT _file.CometExecRule: let the native Iceberg scan output Variant, asCometScanExecalready can.CometIcebergNativeScan: leaveIS NULLandIS NOT NULLon a Variant column in the post-scan filter, as for containers. iceberg-rust cannot bind them (Bind IS NULL and IS NOT NULL on Variant, list, map, and struct fields iceberg-rust#3809), so the residual would fail to bind and be dropped with a warning on every task. Spark infersisnotnull(data)from a predicate such astry_variant_get(data, '$.num', 'int') > 30, so the whole residual of such a filter stays in the post-scan filter, as it already does for containers. Push IS NULL and IS NOT NULL on Variant and container columns to the native Iceberg scan #7838 tracks pushing these null checks.struct<metadata, value>to Spark'sstruct<value, metadata>.A query that reads a Variant column from a data file with neither Parquet field ids nor a name mapping now fails in the native scan instead of falling back, because iceberg-rust rejects that read (
projection.rs) and the planner does not open data files.datatypes.mdandiceberg.mddescribe this, and apache/iceberg-rust#3808 tracks reading these files.How are these changes tested?
CometIcebergNativeSuite: the Variant tests check native reads against Spark for top-level, struct, array, and map Variants, including Variant null and SQL null, a historical snapshot after a rename, Variant columns added by schema evolution after a file was written, andCOUNT(*)and_filescans of a table with a Variant column.CometIcebergNativeSuite:shredded variant columns read nativelywrites shredded object, array, and timestamp Variants with Iceberg's writer, checks that the data file hastyped_valuefor each column, and checks native reads against Spark. Iceberg 1.11 shreds only top-level Variants, so the iceberg-rust tests cover nested shredded Variants. Without feat(arrow): read shredded variant columns iceberg-rust#3683 this test fails withFeatureUnsupported.CometIcebergNativeScanVariantSuitechecks that Variant null residuals are not serialized.TestSparkVariantReadandTestVariantShredding.AI usage disclosure
I wrote this PR with help from Claude but understand and support the core approach, implementation, and test coverage.