Repository navigation
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 #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 #7106 until apache/datafusion#27065 is fixed (#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 #6880 PartialMerge test with a 2 MiB pool. The #6254 and #6857 read-back tests, which the pool was added for, pass without it. The sort-merge join #6880 test now uses an 8 MiB pool, because with DataFusion 56 its PartialMerge fits in 12 MiB or more without spilling. Closes #6583.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
viirya
left a comment
There was a problem hiding this comment.
Thanks for carrying this upgrade. Most of the API migration is mechanical and reads cleanly. Removing SpillReplayPool is a nice reduction if it holds up, and I left questions on that inline.
A couple of things that aren't tied to a line:
Closes #7541relies on apache/datafusion#26743, but nothing here exercises that fix. Could you add the issue'sANY_VALUE(array<string>)reproducer as a test?- The description has drifted from the diff in a few places: the iceberg revisions, the NaN known issue (now fixed, which closes #7242), native-executors "stays on its previous pin", and the spill replay pool. Could you refresh it?
| name: ubuntu-latest/native-executors | ||
| if: ${{ !inputs.cache-refresh-only && inputs.profiles != 'nightly' }} | ||
| # if: ${{ !inputs.cache-refresh-only && inputs.profiles != 'nightly' }} | ||
| if: false |
There was a problem hiding this comment.
Preflight rejects this because the job loses its cache-refresh-only and nightly guards. Since then every other job has been skipped, so nothing has run against the crates.io 56.0.0 build. Something like if: ${{ false && !inputs.cache-refresh-only && inputs.profiles != 'nightly' }} should keep Preflight happy. The comment above, and the one in native-executors/Cargo.toml, still say Comet is on the 56.0.0 tag.
There was a problem hiding this comment.
Ballista main is on the DataFusion 56.0.0 release now, so I moved native/native-executors to Ballista 5a387e1, and DataFusion and datafusion-proto to 56.0.0 from crates.io. The workspace resolves one copy of DataFusion again and builds and passes clippy locally, so the job is back on with main's original if:. The comments in the workflow and in native-executors/Cargo.toml are updated too. (ad6ed8c)
There was a problem hiding this comment.
The job builds now, but runs_a_query_across_a_range_exchange fails with CometFragmentExec input 0 has 4 partitions, expected 1 from EnsureRequirements. Is that a change on Ballista main, or does Comet's fragment need to report its partitioning differently on 56?
| off_heap_size, | ||
| running_tasks.clone(), | ||
| )), | ||
| tracked(CometFairMemoryPool::with_spark( |
There was a problem hiding this comment.
As I read #25383, the merge's headroom is only a probe. It grows to 2× and then shrinks back before the replay starts. After that, the replay's ClusteredFinalAggregateStream (Full, no spill path) calls try_grow under the FinalHashAggregateStream consumer, which limited_to_its_share still limits. What keeps the replay from failing in these two cases?
- Spark grants that memory elsewhere, or another spillable consumer registers, between the probe and the replay.
- A group grows past the merge buffers, as #25383 itself notes for
array_agg.
1.2 overcommitted in both cases. Do the #6254 or #6857 tests cover either one?
There was a problem hiding this comment.
You're right. In 56.0.0, get_sorted_spill_files_to_merge asks for twice the buffers and then shrinks back to the accepted buffers before the replay (multi_level_merge.rs:612-684). The replay is a Full ClusteredFinalAggregateStream with no spill context, under the outer aggregate's consumer (spill.rs:303-335). Its only fallback is to emit completed groups, and it returns the error when the table holds one group. So both of your cases can still fail the task, and none of the #6254/#6857 tests reach either one. They all run one task with small groups.
I put SpillReplayPool back and updated it for the 56 names: FinalHashAggregateStream, ClusteredFinalAggregateStream, SingleHashAggregateStream, and the new ClusteredSingleAggregateStream, which replays the same way. Its check that the consumer holds more than the growing reservation still identifies the replay in 56, because the merge's headroom check grows and shrinks a single reservation. I added a pool test for case 1, ..._may_pass_a_share_lowered_after_the_merge: the merge probes and releases, a sort becomes active, and the replay's request goes past the lowered share. It fails without the wrapper. The module docs and the memory management guide now say why apache/datafusion#25383 isn't enough. (188f7cd)
There was a problem hiding this comment.
Thanks for restoring it. The two #6880 PartialMerge tests now fail in every [exec] job with an OOM in ClusteredPartialAggregateStream[0]. That looks like the merge starvation from b46499740 again.
As far as I can tell, switch_to_clustered_final_stream builds the replay ClusteredFinalAggregateStream before the merge stream is polled. Its constructor reserves the initial table (clustered_final_stream.rs:188). So when get_sorted_spill_files_to_merge runs, the consumer already holds memory in a sibling reservation. That makes consumer_used > reservation.size() true for the merge's own refusals. Is there another way to tell the merge's reservation from the replay's? The new pool test steps the reservations in the opposite order, so it doesn't catch this.
| /// Spark's string type as those types, not as `Binary`. A malformed value must still decode | ||
| /// to U+FFFD. | ||
| #[tokio::test] | ||
| #[ignore = "DataFusion 56 coerces nested BINARY to unvalidated Utf8: https://github.com/apache/datafusion-comet/issues/7469"] |
There was a problem hiding this comment.
apache/datafusion#27065 is closed by #27067, but that landed on main only, so 56.0.0 doesn't have it. Is the plan to get it backported for a 56.0.1, or to fall back or validate on the Comet side for nested binary read as string?
There was a problem hiding this comment.
The plan is a backport. apache/datafusion#27067 cherry-picks cleanly onto branch-56, and its tests pass there. I opened apache/datafusion#27754 to backport it, so that it can go into a 56.0.1. This PR stays a draft until Comet can use that release. Then the two ignored tests go back on.
There was a problem hiding this comment.
Sounds good. The PR still shows as ready for review, though. Could you convert it to a draft while apache/datafusion#27754 is pending?
| iceberg = { git = "https://github.com/apache/iceberg-rust", rev = "de0a6ac8471da43f63382d66fac27d7e56fd273e" } | ||
| iceberg-storage-opendal = { git = "https://github.com/apache/iceberg-rust", rev = "de0a6ac8471da43f63382d66fac27d7e56fd273e", features = ["opendal-memory", "opendal-fs", "opendal-s3", "opendal-gcs", "opendal-oss", "opendal-azdls", "opendal-hdfs-native"] } | ||
| # version requirement once a release ships on arrow 60. Bump policy: #5645. | ||
| # The revision is on the andygrove/iceberg-rust fork: apache/iceberg-rust#3257 (Arrow 60, |
There was a problem hiding this comment.
apache/iceberg-rust#3257 merged on Nov 10. Can this move back to an upstream main revision that also includes #3539, and drop the fork?
There was a problem hiding this comment.
Done. The fork is gone, and the pin is now 219078c on iceberg-rust main, which includes apache/iceberg-rust#3257 and apache/iceberg-rust#3539. I stopped one commit short of the current head: 986153c moves iceberg-rust to opendal 0.59, and Comet's own opendal and object_store_opendal would have to move with it, so I'd rather do that in its own PR. Two iceberg-rust API changes came along: reader settings now go through ArrowReaderOptions, and FileScanTaskDeleteFile::file_size_in_bytes is an Option. (5c04cc9)
| // Final also reads states from the columns after the keys, so the input must be the keys | ||
| // followed by native states (Spark's binary collect buffers keep Single, and arrive | ||
| // unordered anyway). | ||
| // Drop this on DataFusion 56, where the stream is ClusteredFinalAggregateStream |
There was a problem hiding this comment.
This says to drop the PartialMerge→Final switch on DataFusion 56. Is it still needed? If so, could the comment say why?
There was a problem hiding this comment.
Not for the reason it gives. On 56, Single over partially sorted input runs ClusteredSingleAggregateStream (mod.rs:1422-1428, with enable_migration_aggregate defaulting to true), which spills, and SpillReplayPool now covers its replay. What Final still gets is the name exemption in limited_to_its_share. Removing the switch also means removing the Final path in merge_as_partial.rs, and the #6880 JVM tests need to confirm it, so I filed #7765 for that. The comment now says why the switch exists and links the issue. (1100221)
| // `out[0]`'s extensions) and the clone are live at once, exactly like the real reader. | ||
| let cloned_plan = attached_plan.clone(); | ||
| let metadata = read_metadata_with_page_index(&path); | ||
| // Deprecated in DataFusion 56 in favor of row-group-local entries; these tests still model |
There was a problem hiding this comment.
If the reader now keeps row-group-local entries, does reader_peak_bytes still bound the real peak? If that needs a separate look, could you file an issue and link it here?
There was a problem hiding this comment.
It still bounds it. In 56, ParquetAccessPlan::prepare moves each row group's selection into the push decoder (access_plan.rs:633-693, opener/mod.rs:1761-1773), so the combined selection that term 3 modelled is no longer allocated. What replaced it is the decoder's peek_next_row_group clone of the remaining row groups at row-group boundaries (exact-length) and the active row group's clone. Both are at most selectors, which is less than term 3's 2 * selectors + 6 * num_row_groups. So the bound is a little looser than before, but still an upper bound. I updated the doc comments on reader_peak_bytes and on the reservation, and the comments on the three tests, to say so. (8ebda31)
| /// - a `Dictionary` nested in a list/map: `SparkXxhash64` restarts those hashes from 42 | ||
| /// - `Struct` (and anything containing one): before DataFusion 56, `SparkXxhash64` did not push | ||
| /// a parent null mask into children, so hidden values of a NULL struct would affect the hash | ||
| /// (fixed by apache/datafusion#25774) |
There was a problem hiding this comment.
Two of the reasons for keeping the Comet kernel no longer hold. Could you either widen the routing here or file an issue for it and link it from this comment?
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and turn its CI job back on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…adroom back before the replay Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…taFusion 56 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…routing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. Inline replies are in each thread. On the two general points:
|
mbutrovich
left a comment
There was a problem hiding this comment.
Thanks @andygrove for carrying this upgrade. This review covers only the code comments the upgrade adds or makes stale. Several new comments narrate what DataFusion 55 or arrow 59 did and how 56 or 60 changed it. That history belongs in the PR description and the commit message. A comment should describe the code as it is now, and these will be wrong again at the next upgrade.
The upgrade also makes three comments outside the diff stale.
merge_rows.rs says to go back to and_not once Comet is on arrow 60. The fix for apache/arrow-rs#10698 (apache/arrow-rs#10699) is in 60.1.0. Could we switch back here, or drop the comment if and(.., not(..)) stays?
audit.toml says the zstd advisories are blocked on the arrow 60 upgrade. With this PR arrow-ipc 60.1.0 resolves to zstd 0.14.3, but native/Cargo.lock still has zstd 0.13.3 through datafusion-comet-shuffle (zstd = "0.13.3"), iceberg, and apache-avro. Could you update the comment to name what blocks it now?
topk/reader.rs clears incomplete column statistics because DataFusion 55.1 reads an omitted null_count as zero (apache/datafusion#25239). The fix, apache/datafusion#25242, is in 56.0.0 and in no 55.x release. Is the workaround still needed? If it is, the comment should say why. If not, could we remove it here, since the upgrade is what makes it dead code?
| # The next main revision, 986153c, moves iceberg-rust to opendal 0.59, which needs | ||
| # Comet's opendal and object_store_opendal to move with it. |
There was a problem hiding this comment.
The next iceberg-rust revision and what it would pull in is a note for the PR, and the SHA goes stale with the next bump. Could we drop these two lines and file an issue for moving iceberg-rust to opendal 0.59, so the follow-up the description lists is tracked?
| # The next main revision, 986153c, moves iceberg-rust to opendal 0.59, which needs | |
| # Comet's opendal and object_store_opendal to move with it. |
| /// `(Int64) -> Map(String, Int32)` built through arrow-rs's default | ||
| /// [`MapBuilder`]. | ||
| /// `(Int64) -> Map(String, Int32)` built through a [`MapBuilder`] with | ||
| /// explicit field names. | ||
| /// | ||
| /// That builder names the map's children `entries` / `keys` / `values`, | ||
| /// where Comet's own Spark-to-Arrow conversion emits `entries` / `key` / | ||
| /// `value`. Those names are positional in the Arrow format, so the two | ||
| /// spellings have to be accepted interchangeably; this UDF is what proves | ||
| /// it end to end, since `echo_c` hands back the map Comet gave it and so | ||
| /// always carries Comet's own names. | ||
| /// The names are `entries` / `keys` / `values`, which is what arrow-rs's | ||
| /// default builder used before arrow 60 changed its default to `entries` / | ||
| /// `key` / `value`. Comet's own Spark-to-Arrow conversion emits the latter. | ||
| /// Those names are positional in the Arrow format, so the two spellings | ||
| /// have to be accepted interchangeably; this UDF is what proves it end to | ||
| /// end, since `echo_c` hands back the map Comet gave it and so always | ||
| /// carries Comet's own names. |
There was a problem hiding this comment.
The new text explains what arrow-rs's default was before arrow 60. A reader needs only the names this builder uses and the names Comet emits. Main's wording already said that, so it can stay with the explicit names:
| /// `(Int64) -> Map(String, Int32)` built through arrow-rs's default | |
| /// [`MapBuilder`]. | |
| /// `(Int64) -> Map(String, Int32)` built through a [`MapBuilder`] with | |
| /// explicit field names. | |
| /// | |
| /// That builder names the map's children `entries` / `keys` / `values`, | |
| /// where Comet's own Spark-to-Arrow conversion emits `entries` / `key` / | |
| /// `value`. Those names are positional in the Arrow format, so the two | |
| /// spellings have to be accepted interchangeably; this UDF is what proves | |
| /// it end to end, since `echo_c` hands back the map Comet gave it and so | |
| /// always carries Comet's own names. | |
| /// The names are `entries` / `keys` / `values`, which is what arrow-rs's | |
| /// default builder used before arrow 60 changed its default to `entries` / | |
| /// `key` / `value`. Comet's own Spark-to-Arrow conversion emits the latter. | |
| /// Those names are positional in the Arrow format, so the two spellings | |
| /// have to be accepted interchangeably; this UDF is what proves it end to | |
| /// end, since `echo_c` hands back the map Comet gave it and so always | |
| /// carries Comet's own names. | |
| /// `(Int64) -> Map(String, Int32)` built through a [`MapBuilder`] whose | |
| /// children are named `entries` / `keys` / `values`, where Comet's own | |
| /// Spark-to-Arrow conversion emits `entries` / `key` / `value`. Those names | |
| /// are positional in the Arrow format, so the two spellings have to be | |
| /// accepted interchangeably; this UDF is what proves it end to end, since | |
| /// `echo_c` hands back the map Comet gave it and so always carries Comet's | |
| /// own names. |
| /// Conservative upper bound, in bytes, on the peak allocation live while DataFusion's reader | ||
| /// normalizes one file's attached [`ParquetAccessPlan`]. This, not the plan's own retained | ||
| /// selector bytes, is what the steady-state reservation must cover. Three allocations can be | ||
| /// live at once. Term 3 was measured against DataFusion 55's file-level combined selection; | ||
| /// DataFusion 56 moves each row group's selection into the push decoder instead, and the | ||
| /// copies that replaced it (the decoder's `peek_next_row_group` clone of the remaining row | ||
| /// groups, and the active row group's clone) are at most `selectors`, so term 3 still covers | ||
| /// them: |
There was a problem hiding this comment.
Term 3 still models into_overall_row_selection. DataFusion 56 deprecates it, and the reader no longer calls it. The opener now moves each row group's selection into the decoder. So the doc describes an allocation that no longer happens, then adds a sentence saying it still covers the one that does.
Could we rewrite term 3 to describe the copies 56 makes, with the bound from #7249 (comment)? The same DataFusion 55 model is at lines 389-394, 428, 712, and 912, and the measured allocator peaks below the formula were taken on the old path. If the formula stays larger than 56 needs on purpose, one sentence saying so is enough.
There was a problem hiding this comment.
Rewrote term 3 to describe the decoder's copies: the peek_next_row_group clone of the queued row groups and the active row group's clone. Both are exact-length, and together they are at most selectors. One sentence says the formula keeps charging the larger file-level combined selection on purpose, and that the measured peaks were taken on that reader. The code comment on term 3 and the comments at 712 and 912 say the same. #7766 tracks measuring the current reader and tightening the bound. (a87c14f)
| /// Replays DataFusion 55's reader-normalization path: clones the attached plan exactly as | ||
| /// `create_initial_plan` does, calls `ParquetAccessPlan::into_overall_row_selection`, which | ||
| /// DataFusion 55 called from `build_stream` and whose combined selection is at least as | ||
| /// large as the per-row-group copies DataFusion 56 makes instead, and recovers the resulting `RowSelection`'s TRUE backing `Vec` capacity |
There was a problem hiding this comment.
This test and the two below it now check the reservation against a deprecated function the reader doesn't run. Lines 2119-2122 say exercising the real dependency keeps the test honest across upgrades, and line 2335 says the call mirrors "how the real reader calls it". Neither holds on 56. The tests also stop compiling when DataFusion removes into_overall_row_selection.
Could these tests measure what 56 allocates instead? ParquetAccessPlan::prepare is pub(crate), so that likely means scanning the file with the plan attached. If that doesn't fit in this PR, could you file an issue for it and change the docs and the comments at lines 2167, 2239, and 2339 to say what the tests check now?
There was a problem hiding this comment.
Measuring what 56 allocates needs a scan with the plan attached, since prepare is pub(crate), so I filed #7766 for it, including moving these tests off into_overall_row_selection before DataFusion removes it. The docs, the comments you pointed at, and the assert messages now say the tests check the combined selection that term 3 charges for, not an allocation the reader makes. I removed the claim about exercising the real dependency. (a87c14f)
| consumer.can_spill() && !consumer.name().starts_with(CLUSTERED_FINAL_AGGREGATE) | ||
| } | ||
|
|
||
| /// The name prefix of the consumer that DataFusion 55.2's `ExternalSorter` registers for what it |
There was a problem hiding this comment.
This PR drops "DataFusion 55.2" from the doc at line 221, but this line, line 254, line 1048, and line 1109 still name 55.2 for behavior Comet now gets from 56. Line 1048 sits right under the new "DataFusion 56" text at line 1044. Could we drop the version from these as line 221 does, after checking that 56 still behaves as each one says?
There was a problem hiding this comment.
Dropped the version from all four. I checked each against 56 first: ExternalSorter[ and ExternalSorterMerge[ are still the consumer names (sort.rs:334-343), the hash aggregates keep their output reserved until it is emitted and emit slices (hash_stream.rs:445-489), and FinalHashAggregateStream spills (hash_stream.rs:695-731). Three more comments in the file said "DataFusion 56's aggregates reserve...", so they now say "The aggregates reserve...". (b5c92ca)
| // The same import `RecordBatchStreamReader::next` performs. (Arrow 60 made the | ||
| // `FFI_ArrowArrayStream` callbacks private, so a hand-rolled stream is no longer possible.) |
There was a problem hiding this comment.
The parenthetical explains why the test doesn't build a stream, which is worth keeping. It can say that in the present tense:
| // The same import `RecordBatchStreamReader::next` performs. (Arrow 60 made the | |
| // `FFI_ArrowArrayStream` callbacks private, so a hand-rolled stream is no longer possible.) | |
| // The same import `RecordBatchStreamReader::next` performs. The `FFI_ArrowArrayStream` | |
| // callbacks are private, so the test can't build a stream for the reader to import. |
| // A PartialMerge over input sorted on some of its keys runs as Final, as a | ||
| // ClusteredFinalAggregateStream, which the fair pool exempts from its fair limit | ||
| // (`limited_to_its_share`). It was added because DataFusion 55 ran Single there with the | ||
| // legacy GroupedHashAggregateStream, whose spill could fail against that limit (#6880). | ||
| // DataFusion 56 runs Single there as a ClusteredSingleAggregateStream, which spills, so | ||
| // this may no longer be needed (#7765). MergeAsPartial evaluates to its state | ||
| // under Final as under Single. |
There was a problem hiding this comment.
The reason this switch exists today is the fair pool's exemption for Final. How DataFusion 55 ran Single is history, and #7765 already holds the question of whether 56's Single would do. Could we keep the why and drop the versions?
| // A PartialMerge over input sorted on some of its keys runs as Final, as a | |
| // ClusteredFinalAggregateStream, which the fair pool exempts from its fair limit | |
| // (`limited_to_its_share`). It was added because DataFusion 55 ran Single there with the | |
| // legacy GroupedHashAggregateStream, whose spill could fail against that limit (#6880). | |
| // DataFusion 56 runs Single there as a ClusteredSingleAggregateStream, which spills, so | |
| // this may no longer be needed (#7765). MergeAsPartial evaluates to its state | |
| // under Final as under Single. | |
| // A PartialMerge over input sorted on some of its keys runs as Final, as a | |
| // ClusteredFinalAggregateStream, which the fair pool exempts from its fair limit | |
| // (`limited_to_its_share`). #7765 tracks whether Single, which runs a | |
| // ClusteredSingleAggregateStream there, would now do. MergeAsPartial evaluates to its | |
| // state under Final as under Single. |
The module doc in merge_as_partial.rs gives the same DataFusion 55 reason ("Single falls back to a stream whose spill can ask for more than its share"), which no longer holds on 56. Could it get the same rewrite?
There was a problem hiding this comment.
| // Arrow 59 rejected both dictionaries only for their empty entry, which Arrow 60 accepts | ||
| // (apache/arrow-rs#10352), so they no longer reach the empty-key retry. Arrow does not reject | ||
| // the rest: an unsorted dictionary may repeat an entry, and bytes after the last offset are | ||
| // never read. The row passes through unchanged, as in Spark, which checks only the offsets | ||
| // of the keys it looks up. |
There was a problem hiding this comment.
| // Arrow 59 rejected both dictionaries only for their empty entry, which Arrow 60 accepts | |
| // (apache/arrow-rs#10352), so they no longer reach the empty-key retry. Arrow does not reject | |
| // the rest: an unsorted dictionary may repeat an entry, and bytes after the last offset are | |
| // never read. The row passes through unchanged, as in Spark, which checks only the offsets | |
| // of the keys it looks up. | |
| // Arrow accepts an empty entry in an unsorted dictionary (apache/arrow-rs#10352), so these | |
| // don't reach the empty-key retry. Arrow does not reject the rest: an unsorted dictionary | |
| // may repeat an entry, and bytes after the last offset are never read. The row passes | |
| // through unchanged, as in Spark, which checks only the offsets of the keys it looks up. |
| //! | Struct NULL with hidden children | yes since DataFusion 56 (apache/datafusion#25774), but not routed | | ||
| //! | List<Dictionary> | yes since DataFusion 56 (apache/datafusion#25813), but not routed | |
There was a problem hiding this comment.
"Since DataFusion 56" is history once Comet moves past 56. The table only needs the current state and where the routing is tracked:
| //! | Struct NULL with hidden children | yes since DataFusion 56 (apache/datafusion#25774), but not routed | | |
| //! | List<Dictionary> | yes since DataFusion 56 (apache/datafusion#25813), but not routed | | |
| //! | Struct NULL with hidden children | yes (apache/datafusion#25774), but not routed (#7764) | | |
| //! | List<Dictionary> | yes (apache/datafusion#25813), but not routed (#7764) | |
| /// `SparkXxhash64` used to hash the hidden child values of a NULL struct. DataFusion 56 fixed it | ||
| /// (apache/datafusion#25774), so upstream now agrees with the Comet kernel here. |
There was a problem hiding this comment.
The test name and the assertion message already say that upstream matches the Comet kernel here. What SparkXxhash64 used to do is history. Could we drop this doc, the one at lines 1039-1040, and the comment at lines 1184-1185?
| /// `SparkXxhash64` used to hash the hidden child values of a NULL struct. DataFusion 56 fixed it | |
| /// (apache/datafusion#25774), so upstream now agrees with the Comet kernel here. |
arrow 60.1 fixes and_not for inputs with a non-zero offset (apache/arrow-rs#10698), so the and(.., not(..)) workaround is no longer needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DataFusion 56 reads an omitted null_count as unknown (apache/datafusion#25242), so the TopK no longer needs to clear incomplete statistics before attaching its filter to the Parquet reader, or to skip attachment when the scan has a static predicate. It now attaches through try_attach_parquet_reader_filter like the min/max and join filters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Term 3 now describes the copies DataFusion 56's reader makes, and says the formula keeps the larger file-level charge on purpose. The three tests that use into_overall_row_selection say they check the formula, not the reader. #7766 tracks measuring the reader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop DataFusion and arrow version history from comments the upgrade added or made stale, and name what still pulls in zstd 0.13 in audit.toml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @mbutrovich. Inline replies are in each thread. On the three comments outside the diff:
The description is updated to match. |
sunchao
left a comment
There was a problem hiding this comment.
Thanks @andygrove, the write-up makes this easy to review. The source changes look mechanical and right to me. I have one likely issue in the fair pool and one thing to confirm for TopK.
1. fair_pool.rs, limited_to_its_share
spill_replay.rs now treats ClusteredSingleAggregateStream as a final aggregate, but the fair pool exemption still covers only ClusteredFinalAggregateStream[. The planner keeps Single for a PartialMerge over fully sorted input ("with fully sorted input Final has no spill path"). On DataFusion 56 that runs as ClusteredSingleAggregateStream with GroupClusteringMode::Full. If that stream, like the Final one, registers as spillable (the apache/datafusion#17334 workaround) but has no spill path when fully sorted, a refusal at the fair limit would fail the query. On 55 it ran as GroupedHashAggregateStream, which could spill.
Could you check whether it needs the same exemption? A test like a_sort_that_fills_the_share_leaves_room_for_the_final_aggregate_above_it, using a Single aggregate over a fully sorted input, would settle it.
2. topk.rs, build_runtime_sort
The reader gets the filter produced by sort, and then sort is rebuilt through replace_children. This relies on SortExec::with_new_children keeping the same DynamicFilterPhysicalExpr rather than creating a fresh one. Otherwise the reader's filter never tightens, which costs performance but not correctness. I believe live_threshold_reaches_remapped_parquet_column_and_prunes_later_groups would catch that. Could you confirm it ran on this branch? An explicit check that produced_topk_filter on the rebuilt sort returns the same expression id as the reader's filter would make it obvious.
3. Minor: join.rs, install_probe_filter
Is the .builder().build() round trip only to get an owned HashJoinExec from the Arc<dyn ExecutionPlan>? If so, would .clone() after the downcast be clearer? It would also avoid any doubt about whether the builder keeps the dynamic filter we just installed.
Heads-up on merge order: #6246 adds a parameter to init_datasource_exec and touches about 25 test call sites, so whichever of the two lands second needs a rebase. I checked their logic against each other. #6246 reads top-level strings as Binary and decodes them, which sidesteps the file-schema coercion that apache/datafusion#25193 makes recursive, so they shouldn't conflict beyond the signature.
Which issue does this PR close?
Part of #6410, which tracks the regressions this PR finds. Closes #7541 and #7242.
The nested BINARY UTF-8 regression is tracked in #7469. Its upstream fix, apache/datafusion#27067, is on DataFusion
mainbut not in 56.0.0. This PR is a draft and is not meant to merge until that fix is released in a 56.0.x patch release and Comet uses it.This replaces #6404, moving the branch from a fork to
datafusion-56in this repository.Rationale for this change
DataFusion 56.0.0 moves to arrow/parquet 60.1.0 and object_store 0.14.2 (apache/datafusion#25335, apache/datafusion#26867), and it has a number of API changes (see its 56.0.0 upgrade guide). Building Comet against it now surfaces the breaks early and lets CI run the Comet suites against it.
What changes are included in this PR?
Dependencies
datafusion,datafusion-datasource,datafusion-functions,datafusion-physical-expr-adapteranddatafusion-sparkin the workspace now use the 56.0.0 release from crates.io. So do thedatafusion-functions-nesteddev-dependency in core anddatafusionin both contrib crates.arrow,arrow-data,arrow-selectandparquetgo from 59.2.0 to 60.1.0.object_storegoes from 0.13.2 to 0.14.2.object_store_opendalgoes from 0.58.0 to 0.59.0, the first release on object_store 0.14. That release keeps opendal on 0.58, which is what the iceberg-rust revision below uses.parking_lotgoes from 0.12 to 0.13, the version DataFusion'sLazyBatchGeneratorAPI now uses.icebergandiceberg-storage-opendalmove to219078con iceberg-rustmain. It includes Bump to Arrow 60 iceberg-rust#3257 ("Bump to Arrow 60") and fix(writer): skip NaN min/max when aggregating Parquet column bounds iceberg-rust#3539, which skips NaN min and max statistics in manifest bounds.ArrowReaderBuildernow takes its settings asArrowReaderOptions, andFileScanTaskDeleteFile::file_size_in_bytesis now anOption.iceberg_scan.rsuses the new API.native/Cargo.lock,native/native-executors/Cargo.lockandcontrib/delta/native/Cargo.lockare regenerated.native/native-executorsmoves Ballista to5a387e1on itsmainbranch, which uses the DataFusion 56.0.0 release, and DataFusion anddatafusion-prototo the 56.0.0 release. The workspace builds with one copy of DataFusion again, so itslinux-test-native-executorsCI job is back on. Ballista has not released 56.0.0 yet.Source changes (all forced by the upgrade)
ArrowArrayStreamReaderin favor ofRecordBatchStreamReader, andFixedSizeListArray::value_offsetin favor ofvalue_offset_at. Comet uses the new names.FFI_ArrowArrayStreamcallbacks private, so the decimal-realignment test inscan.rscan no longer build a hand-rolled C stream. It now exports a struct array and imports it withfrom_ffi_and_data_type, the callRecordBatchStreamReader::nextmakes.AlignedArrowStreamReaderwas already gone on main.ParquetMetaData::page_index(), aPageIndexProviderwith per-row-group access.with_spark_arrow_schemaand the rebase footer rewrite carry it over withset_page_index.page_selection_bound_selectorsindelta_dv.rswalks the row groups throughpage_index_for_row_group.page_index()instead ofcolumn_index()/offset_index().AggregateExec::input_order_mode()is nowgroup_clustering_mode(), returning aGroupClusteringMode. Two planner tests and amin_max_structtest use it.OrderedFinalAggregateStreamand its memory consumer toClusteredFinalAggregateStream. The fair pool's exemption andSpillReplayPool's final-aggregate check match that consumer by name, so they now match the new name. Without this they silently stopped applying.SpillReplayPoolalso coversClusteredSingleAggregateStream, which DataFusion 56 runs for aSingleaggregate over input sorted on some of its keys and which replays its spill files the same way.a_final_aggregate_reading_its_spill_files_back_may_pass_a_share_lowered_after_the_merge, covers the second case.coerce_int96andcoerce_int96_tzare now typed (DFTimeUnit,ConfigTimeZone) instead of strings.GetResult::extensions, whichScanIoObjectStore::get_optsnow forwards.OffsetBuffer::first()/last()now return values instead ofOptions.Metadatatype. The datetime rebase resolution reads it directly, and the shuffle schema cache's size estimate useslen()instead ofcapacity().fb_to_schemais deprecated. The shuffle decoder usestry_fb_to_schema, so an invalid schema message now returns a decode error where it used to panic.FFI_ArrowSchema::with_metadatais nowunsafe. The call inmove_to_sparkis sound because the schema was just built byTryFrom.HashJoinExec::with_dynamic_filter_exprandSortExec::with_dynamic_filter_exprare deprecated with no replacement, and Comet no longer calls them.SortExecwith a fetch creates for itself (dynamic_expressions_produced()) and hands it to the Parquet reader below the sort.DynamicFilterJoinExecreports toHashJoinExec::handle_child_pushdown_resultwhat DataFusion'sFilterPushdownrule would, namely that the probe-side self filter was pushed down. The join then installs the filter itself, after finding Comet's consumer in its probe subtree.#[allow(deprecated)]:ExecutionPlan::with_preserve_order, which DataFusion no longer calls.MetricOwningExeckeeps forwarding it.ParquetAccessPlan::into_overall_row_selection, in threedelta_dv.rstests. DataFusion 56's reader no longer builds that file-level selection. It moves each row group's selection into the parquet push decoder, and the decoder's copies are at most the retained selectors.reader_peak_byteskeeps charging term 3 as the larger combined selection, so it is still an upper bound. Its doc comment now describes the decoder's copies, and the three tests say they check the formula, not the reader. Measure the Delta deletion vector reader peak on DataFusion 56 and tighten reader_peak_bytes #7766 tracks measuring the reader and moving the tests off the deprecated call.normalize_spark_empty_key_metadata_rejects_other_malformed_encodings: Arrow 60 accepts empty entries in unsorted Variant dictionaries (Addproptestfuzzing to parquet-variant and implement fixes for findings arrow-rs#10352).make_map_cincomet-test-udfs: arrow 60'sMapBuildernames the map childrenkey/valueby default, so the test UDF now names themkeys/valuesexplicitly to keep exercising non-canonical names.merge_rows.rsgoes back toand_notfor the not-matched masks. arrow 60.1 fixes it for inputs with a non-zero offset (and_not produces incorrect values for sliced BooleanArray arrow-rs#10698).null_countbefore attaching its filter to the reader. DataFusion 56 reads an omitted count as unknown (fix: preserve missing Parquet null counts datafusion#25242).topk/reader.rsis gone, and the TopK attaches throughtry_attach_parquet_reader_filterlike the min/max and join filters. It also attaches when the scan has a static predicate, which it skipped before because clearing statistics could expose a file that predicate excluded.static_range_with_unknown_null_count_keeps_hiding_an_excluded_filechecks that it attaches and that the static predicate still hides the file.datafusion-spark'sSparkXxhash64now ignores the hidden children of a NULL struct (fix: xxhash64 of a NULL struct ignores the struct fields datafusion#25774) and keeps the running hash for nested dictionaries (fix: keep the running hash for nested dictionaries in Spark xxhash64 datafusion#25813). Three tests inxxhash64_diff.rsthat pinned those differences now assert equality. Comet still keeps its own kernel for those types. Route struct and nested dictionary xxhash64 arguments to datafusion-spark's SparkXxhash64 #7764 tracks widening the routing.Known issue: invalid UTF-8 in nested BINARY values read as strings
apache/datafusion#25193 made DataFusion's Parquet file-schema coercion recurse into nested types, so a nested BINARY field that the read schema declares as a string is decoded straight into
Utf8. The parquet reader validates UTF-8 only for columns with theUTF8annotation, so an invalid value produces an unvalidatedStringArray: a panic in debug builds, and unsound data in release builds. Onmain, #7106 decodes these values to U+FFFD. This PR ignores #7106's Rust test (nested_arrow_binary_types_read_as_string_decode_invalid_utf8) and JVM test (ParquetReadSuite"native scan decodes invalid UTF-8 in nested BINARY read as string"). The issue is tracked in #7469 and was reported upstream as apache/datafusion#27065. apache/datafusion#27067 fixes it on DataFusionmain. It cherry-picks cleanly ontobranch-56, and this PR needs it in a 56.0.x release before it merges. Then the two tests are turned back on.DataFusion behavior changes checked against Comet
floor/ceilreturn types and the result ofmap_extractfor absent keys changed. Comet registers its ownfloor,ceilandmap_extract, so neither change reaches Comet.Not included (possible follow-ups)
proptestfuzzing to parquet-variant and implement fixes for findings arrow-rs#10352, so the encoded-metadata decoding and the empty-key retry (canonicalize_spark_empty_key_metadata) can now be removed.reader_peak_bytes.stack. feat: support Spark-compatiblestackfunction datafusion#26266 is in 56.0.0 (6489d15).Final.How are these changes tested?
CometAggregateSuite"any_value of an array of strings reserves only what it keeps (issue ANY_VALUE memory regression in Comet 1.2.0 #7541)" runs the reproducer from ANY_VALUE memory regression in Comet 1.2.0 #7541 with a 16 MiB pool. It fails onmainwith the error from the issue ("Failed to acquire 52135888 bytes ... the pool limit is 16777216 bytes" inOrderedFinalAggregateStream) and passes on this branch.spill_replay.rshas a new test for a fair share lowered between the merge's headroom check and the replay. It fails without the wrapper.CometIcebergWriteActionSuite"native acceleration: NaN float/double manifest metrics match the JVM writer" runs again, now that the iceberg-rust revision includes fix(writer): skip NaN min/max when aggregating Parquet column bounds iceberg-rust#3539.cargo fmtandcargo clippy --all-targets --workspace -- -D warningsare clean innative/andnative/native-executors. The native tests for the memory pools, Iceberg scan,delta_dv, aggregate planner, dynamic filters,merge_rowsand xxhash64 pass.run-all-spark-profiles,run-spark-4.1-testsandrun-iceberg-testslabels.