mbutrovich commented on code in PR #7249:
URL: https://github.com/apache/datafusion-comet/pull/7249#discussion_r4697298336
##########
native/Cargo.toml:
##########
@@ -85,9 +85,11 @@ aws-credential-types = "1.2.13"
aws-sdk-sts = { version = "1.114.0", default-features = false }
# Pinned to a revision rather than a release because no published iceberg-rust
# version is on our arrow: 0.10.1 requires arrow/parquet ^58. Move to a plain
-# version requirement once a release ships on arrow 59. Bump policy: #5645.
-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 next main revision, 986153c, moves iceberg-rust to opendal 0.59, which
needs
+# Comet's opendal and object_store_opendal to move with it.
Review 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?
```suggestion
```
##########
native/core/src/execution/delta_dv.rs:
##########
@@ -2102,10 +2112,10 @@ mod tests {
assert!(matches!(err, GeneralError(_)), "unexpected error: {err:?}");
}
- /// Replays DataFusion 54.1's REAL reader-normalization path (not a
reimplementation of
- /// it): clones the attached plan exactly as `create_initial_plan` does,
calls the actual,
- /// public `ParquetAccessPlan::into_overall_row_selection` DataFusion will
call from
- /// `build_stream`, and recovers the resulting `RowSelection`'s TRUE
backing `Vec` capacity
+ /// 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
Review 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](https://github.com/apache/datafusion-comet/blob/11002211a3c4ede37f3775b0afc5ec57eaca9e04/native/core/src/execution/delta_dv.rs#L2334-L2336)
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?
##########
native/core/src/execution/operators/scan.rs:
##########
@@ -525,31 +468,27 @@ mod import_tests {
.add_buffer(under_aligned)
.build_unchecked()
};
-
- let schema: SchemaRef = Arc::new(Schema::new(vec![Field::new(
- "d",
- decimal_type.clone(),
- false,
- )]));
+ let fields = Fields::from(vec![Field::new("d", decimal_type, false)]);
let struct_data = unsafe {
- ArrayData::builder(DataType::Struct(schema.fields().clone()))
+ ArrayData::builder(DataType::Struct(fields.clone()))
.len(2)
.add_child_data(decimal)
.build_unchecked()
};
-
- let stream = one_batch_stream(Arc::clone(&schema), struct_data);
- let mut reader = ArrowArrayStreamReader::try_new(stream).unwrap();
- let batch = reader.next().unwrap().unwrap();
- let col = batch
- .column(0)
+ let array = FFI_ArrowArray::new(&struct_data);
+
+ // The same import `RecordBatchStreamReader::next` performs. (Arrow 60
made the
+ // `FFI_ArrowArrayStream` callbacks private, so a hand-rolled stream
is no longer possible.)
Review Comment:
The parenthetical explains why the test doesn't build a stream, which is
worth keeping. It can say that in the present tense:
```suggestion
// 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.
```
##########
native/core/src/execution/delta_dv.rs:
##########
@@ -364,10 +364,14 @@ const VEC_GROWTH_CAPACITY_FACTOR: usize = 2;
/// is tiny still pays this floor.
const MIN_VEC_CAPACITY_SELECTORS: usize = 4;
-/// Conservative upper bound, in bytes, on the peak allocation live while
DataFusion 54.1'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 when `into_overall_row_selection` returns:
+/// 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:
Review Comment:
Term 3 still models `into_overall_row_selection`. DataFusion 56 [deprecates
it](https://github.com/apache/datafusion/blob/7e7ae72a820e2bf87da1205b96639fba334ed2f7/datafusion/datasource-parquet/src/access_plan.rs#L529-L536),
and the reader no longer calls it. The opener now [moves each row group's
selection into the
decoder](https://github.com/apache/datafusion/blob/7e7ae72a820e2bf87da1205b96639fba334ed2f7/datafusion/datasource-parquet/src/opener/mod.rs#L1757-L1773).
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
https://github.com/apache/datafusion-comet/pull/7249#discussion_r4696489854?
The same DataFusion 55 model is at [lines
389-394](https://github.com/apache/datafusion-comet/blob/11002211a3c4ede37f3775b0afc5ec57eaca9e04/native/core/src/execution/delta_dv.rs#L389-L394),
[428](https://github.com/apache/datafusion-comet/blob/11002211a3c4ede37f3775b0afc5ec57eaca9e04/native/core/src/execution/delta_dv.rs#L428),
[712](https://github.com/apache/datafusion-comet/blob/11002211a3c4ede37f3775b0afc5ec57eaca9e04/native/core/src/execution/delta_dv.rs#L712),
and
[912](https://github.com/apache/datafusion-comet/blob/11002211a3c4ede37f3775b0afc5ec57eaca9e04/native/core/src/execution/delta_dv.rs#L912),
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.
##########
native/comet-test-udfs/src/lib.rs:
##########
@@ -299,18 +299,30 @@ fn micros(arg: &ArrayRef) ->
Result<TimestampMicrosecondArray, String> {
Ok(arr.iter().collect::<TimestampMicrosecondArray>())
}
-/// `(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.
Review 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:
```suggestion
/// `(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.
```
##########
native/spark-expr/src/hash_funcs/xxhash64_diff.rs:
##########
@@ -800,8 +800,10 @@ fn null_struct_ignores_hidden_child_values_comet() {
);
}
+/// `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.
Review 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?
```suggestion
```
##########
native/core/src/parquet/cast_column/variant/tests.rs:
##########
@@ -977,14 +977,32 @@ fn
normalize_spark_empty_key_metadata_rejects_other_malformed_encodings() {
);
for malformed in [
- vec![1, 3, 0, 1, 1, 2, 0xff, b'a'], // Invalid UTF-8.
- vec![1, 3, 0, 2, 1, 2, b'z', b'a'], // Decreasing offsets.
- vec![1, 3, 0, 1, 1, 2, b'z', b'z'], // Duplicate dictionary keys.
- vec![1, 3, 0, 1, 1, 3, b'z', b'a'], // Out-of-bounds offset.
- vec![1, 3, 0, 1, 1, 2, b'z', b'a', 0], // Unexpected trailing bytes.
+ vec![1, 3, 0, 1, 1, 2, 0xff, b'a'], // Invalid UTF-8.
+ vec![1, 3, 0, 2, 1, 2, b'z', b'a'], // Decreasing offsets.
+ vec![1, 3, 0, 1, 1, 3, b'z', b'a'], // Out-of-bounds offset.
] {
assert!(normalize(&malformed).is_err(), "accepted {malformed:?}");
}
+ // 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.
Review Comment:
```suggestion
// 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.
```
##########
native/core/src/execution/planner/aggregate.rs:
##########
@@ -254,17 +254,17 @@ impl OperatorBuilder for HashAggBuilder {
})
.collect();
- // DataFusion 55 runs Single over input sorted on some of its keys
with the legacy
- // GroupedHashAggregateStream, whose spill can fail against the fair
limit (#6880). Final
- // runs an OrderedFinalAggregateStream there, which spills, and which
the fair pool exempts
- // from that limit (`limited_to_its_share`). 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`). 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.
Review 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?
```suggestion
// 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`](https://github.com/apache/datafusion-comet/blob/f67d51d24aa9cac69a428df2a7b6655e4b042456/native/core/src/execution/merge_as_partial.rs#L30-L32)
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?
##########
native/core/src/execution/memory_pools/fair_pool.rs:
##########
@@ -241,7 +241,7 @@ impl Display for CometFairMemoryPool {
/// keys.
/// `a_sort_that_fills_the_share_leaves_room_for_the_final_aggregate_above_it`
checks both.
fn limited_to_its_share(consumer: &MemoryConsumer) -> bool {
- consumer.can_spill() &&
!consumer.name().starts_with(ORDERED_FINAL_AGGREGATE)
+ 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
Review Comment:
This PR drops "DataFusion 55.2" from the doc at line 221, but this line,
[line
254](https://github.com/apache/datafusion-comet/blob/11002211a3c4ede37f3775b0afc5ec57eaca9e04/native/core/src/execution/memory_pools/fair_pool.rs#L254),
line 1048, and [line
1109](https://github.com/apache/datafusion-comet/blob/11002211a3c4ede37f3775b0afc5ec57eaca9e04/native/core/src/execution/memory_pools/fair_pool.rs#L1109)
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?
##########
native/spark-expr/src/hash_funcs/xxhash64_diff.rs:
##########
@@ -35,8 +35,8 @@
//! | Map<Utf8, Int32> / Map<Int32, Utf8> / Map<Utf8, Utf8>
/ Map<Int32, Int32> | yes |
//! | Map<Utf8, Decimal128> | only for precision ≤ 18 |
//! | Struct (non-null parent) | yes, but not routed (see below) |
-//! | Struct NULL with hidden children | **no** — `SparkXxhash64` hashes
hidden children |
-//! | List<Dictionary> | **no** — upstream restarts from seed 42 |
+//! | 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 |
Review Comment:
"Since DataFusion 56" is history once Comet moves past 56. The table only
needs the current state and where the routing is tracked:
```suggestion
//! | Struct NULL with hidden children | yes (apache/datafusion#25774), but
not routed (#7764) |
//! | List<Dictionary> | yes (apache/datafusion#25813), but not routed
(#7764) |
```
--
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]