ViktorBystrov72 opened a new pull request, #60600:
URL: https://github.com/apache/spark/pull/60600

   ### What changes were proposed in this pull request?
   
   Use an HLL++-specific interpreted hasher for complex values. Include 
null-presence markers and collection lengths while reusing the existing 
primitive, floating-point, and collation-aware hashing logic. Add buffer and 
SQL regressions and a migration note.
   
   ### Why are the changes needed?
   
   [SPARK-61529](https://issues.apache.org/jira/browse/SPARK-61529) reports 
that `approx_count_distinct` estimates about 100 values for 200 distinct arrays 
formed from `[i]` and `[i, NULL]`. Hashing skips nulls and collection 
boundaries, so these pairs systematically collide. The same problem affects 
null positions and nested collection boundaries.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. The estimate for the reported array input is now near its actual 
cardinality, within the configured approximation error. HLL++ hashes for 
complex inputs change. Streaming queries retaining this state must start with a 
new checkpoint to avoid mixing the old and new hashes. The migration guide 
calls this out explicitly.
   
   Primitive HLL++ inputs keep the existing hash path. The register layout and 
public SQL hash functions are unchanged.
   
   ### How was this patch tested?
   
   Before the fix, 10 new Catalyst cases and all 3 SQL cases fail; the two 
representation/floating-equality controls pass.
   
   - Complete `HyperLogLogPlusPlusSuite` and 
`ApproxCountDistinctForIntervalsSuite`: 26 tests passed.
   - SQL regressions: 3 tests passed, covering one/three partitions, 
default/tighter accuracy, and arrays of collated strings.
   - Existing `StreamingStateStoreFormatCompatibilitySuite` 
statistical-functions test: passed, restoring primitive HLL++ state from an 
older checkpoint.
   - Catalyst production/test and SQL test ScalaStyle: passed.
   - Apache RAT: passed with the repository exclusions plus the `.git` worktree 
metadata file.
   
   The new buffer cases cover direct/partial merges, trailing nulls, null 
positions, nested/empty arrays, struct fields, Generic/Unsafe array 
equivalence, signed zero and NaN.
   
   SQL suites emitted possible-daemon-thread-leak warnings in baseline and 
patched runs; the patched checks exited successfully.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex (gpt-6.1-sol; exact tool build unavailable). 
Codex assisted with the implementation, tests, migration note, and this 
description.
   


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