kumarUjjawal commented on code in PR #24646:
URL: https://github.com/apache/datafusion/pull/24646#discussion_r3930657412


##########
datafusion/functions-aggregate/src/approx_distinct.rs:
##########
@@ -880,6 +881,10 @@ impl AggregateUDFImpl for ApproxDistinct {
 /// [`HllGroupsAccumulator`]. The fixed-domain types (booleans / small ints) 
and
 /// `Null` fall back to the per-group [`Accumulator`] path.
 fn is_hll_groups_type(data_type: &DataType) -> bool {
+    if let DataType::Dictionary(_, value_type) = data_type {

Review Comment:
   Recursing here returns false for dictionaries containing Boolean, small 
integers, or Null, because those plain types use specialized scalar 
accumulators. The grouped executor then creates one HLLAccumulator per group 
through GroupsAccumulatorAdapter; each accumulator embeds a 16 KiB sketch. A 
dictionary-encoded Boolean with 100,000 groups can therefore consume about 1.5 
GiB for sketches alone. Please route every supported dictionary through 
HllGroupsAccumulator, or provide a compact dictionary-aware fallback, and add a 
path-sensitive regression for a fixed-domain dictionary.



##########
datafusion/functions-aggregate/src/approx_distinct.rs:
##########
@@ -840,6 +840,7 @@ impl AggregateUDFImpl for ApproxDistinct {
             | DataType::Map(_, _)
             | DataType::Struct(_)
             | DataType::Union(_, _)
+            | DataType::Dictionary(_, _)

Review Comment:
   The unconditional arm accepts dictionaries whose value type remains 
intentionally unsupported. 
   
   For example, Dictionary(Int32, Float64) reaches HLLAccumulator, whose 
hashing path supports floats, although plain Float64 returns NotImplemented. 
Grouped aggregation also bypasses the restriction through 
GroupsAccumulatorAdapter. 
   
   We can validate the value type recursively with a shared supported-type 
predicate and add a negative float-dictionary regression.



-- 
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]

Reply via email to