Add Spark-compatible xxHash64 function
Closes: https://github.com/ClickHouse/ClickHouse/issues/107847
Adds xxHash64Spark, a Spark-compatible variant of xxHash64 that uses seed 42 and returns Int64. This helps users compare or migrate hashes produced by Spark's xxhash64 without manual conversion.
Changelog category (leave one):
- New Feature
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added function xxHash64Spark, which computes Spark-compatible xxHash64 values using seed 42 and returns Int64.
@rschu1ze please provide the approval for the workflow. Thanks.
Workflow [PR], commit [e6d95657]
Summary: ✅
- Performance Comparison: Performance dashboard
AI Review
Summary
This PR adds xxHash64Spark as a single-argument String/NULL wrapper around xxHash64 with Spark's seed 42 and Int64 return type. The earlier arity, type, and NULL-handling problems are fixed, but the final implementation still leaves the signed Int64 projection to an implicit UInt64 -> Int64 conversion and the new test only covers a positive hash value, so the Spark Long contract is not fully pinned down yet.
Findings
⚠️ Majors
- [src/Functions/FunctionsHashing.h:765]
xxHash64Sparkpromises Spark's signed 64-bit result, butXXH_INLINE_XXH64returnsUInt64and the current code relies on the later implicit conversion intoColumnVector<Int64>to reinterpret hashes aboveINT64_MAX. That conversion is implementation-defined, and the regression test does not cover any negative output (xxHash64Spark('a')is-8582455328737087284), so half of the hash space is only correct as a compiler assumption. Suggested fix: return an explicitInt64bit reinterpretation here (for example withbit_cast<Int64>) and add a negative-value stateless test to lock in Spark's signedLongsemantics.
Final Verdict
- Status: ⚠️ Request changes
- Minimum required actions: make the signed
UInt64 -> Int64mapping explicit inxxHash64Sparkand add one negative-value regression test.
@rschu1ze I have implemented spark-compatible xxHash64. Please take a look. Thanks.
LLVM Coverage Report
| Metric | Baseline | Current | Δ |
|---|---|---|---|
| Lines | 85.80% | 85.80% | +0.00% |
| Functions | 92.70% | 92.70% | +0.00% |
| Branches | 77.90% | 77.90% | +0.00% |
Changed lines: Changed C/C++ lines covered: 36/36 (100.00%) · Uncovered code