sunchao commented on code in PR #6927:
URL: https://github.com/apache/datafusion-comet/pull/6927#discussion_r4253196841
##########
spark/src/main/scala/org/apache/comet/serde/aggregates.scala:
##########
@@ -1475,14 +1475,16 @@ object AggSerde {
/**
* Shared support level for `Min` / `Max` based on the result data type.
Floats follow Spark's
- * ordering natively, so strict floating-point mode does not apply to them.
+ * ordering natively, so strict floating-point mode does not apply to them.
Spark and the native
+ * accumulators both compare strings and binary as unsigned bytes, except
that Spark orders a
+ * string with a non-default collation by that collation.
*/
- def minMaxSupportLevel(dt: DataType): SupportLevel = {
- if (!minMaxDataTypeSupported(dt)) {
- Unsupported(Some(s"Unsupported data type: $dt"))
- } else {
- Compatible()
- }
+ def minMaxSupportLevel(dt: DataType): SupportLevel = dt match {
+ case _: StringType if isStringCollationType(dt) =>
+ Unsupported(Some(ComparisonUtils.nonDefaultCollationReason("min/max")))
+ case _: StringType | BinaryType => Compatible()
Review Comment:
[P2] Account retained byte-buffer capacity before enabling grouped
string/binary aggregates. This newly routes queries such as `SELECT k, min(s),
collect_set(tag) FROM t GROUP BY k` to DataFusion 55.2.0’s
`MinMaxBytesAccumulator`. When a long value is replaced by a shorter extremum
in a later batch, `set_value` clears and reuses its `Vec`, retaining capacity,
while `size()` counts only the replacement length. A bounded probe retained
16,783,360 bytes while reporting 6,400 bytes. DataFusion derives aggregate
reservations from this value, so it releases budget for still-live state and
can continue accumulating wide groups without the expected spill pressure. The
same defect affects `max`, binary values, and partial-state merges. These types
previously fell back to Spark. Please account allocated capacities separately
from output lengths, release excess capacity, or retain fallback until the
accumulator is fixed.
Evidence: Compiled the unchanged `datafusion-functions-aggregate` 55.2.0
`src/min_max/min_max_bytes.rs` from a download matching `Cargo.lock` checksum
`fd6c3aee9f2bc65716787d651e023743a90b4efbc57a2f679f036632e16fb110`.
Reproduction: four cohorts of 64 groups; each receives a 65,536-byte value,
followed in a separate batch by a one-byte winning value. For min, use repeated
`z` followed by `a`; reverse them for max. Drop input arrays before measuring
outstanding allocations with a tracking allocator. All eight combinations of
Utf8/Binary, min/max, and update_batch/merge_batch reported 6,400 bytes while
retaining 16,783,360 bytes, with correct final values. Probe and output:
`/tmp/pr6927-current-review-e5gs62z6/memory_probe.rs` and `memory_probe.out`.
DataFusion 55.2.0 `aggregate_hash_table/common.rs:271` sums accumulator
`size()` for reservation accounting; `grouped_hash_stream.rs:983` does
likewise. Probe dependency limitations are stated in the review body.
--
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]