You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement xxhash algorithms as part of the expression API #14044
I'd like the hashing functions xxhash32 and xxhash64 to be part of datafusion expression API so the functions can be used in SQL context for hashing data.
That is true, although, my concern comes from this other issue raised in delta-rs project (link below), since I need to use this hash operation in a Delta merge operation.
Unless I change the codebase for the delta-rs project, I'd be unable to create an UDF (not sure if there's a way to create and register it in the delta-rs context in python, sounds complicated)
Can I take this up? I shall add the new functions in a new file in crypto/xxhas.rs similar to the crypto/sha224.rs file and import them in the crypto/mod.rs file. And then add some tests.
I was wondering how to add support for a None or empty values. Should I replace the input with "NULL" string whenever a None value is entered?
There is also the concern of not taking the seed from the user. Currently the seed is given a default value and I think having the user's control over it be helpful.
If we decide to ask for a seed by the user, do we keep the default to be 0? Wouldn't obfuscating that default values cause issues for the user?
I have added support for individual values of the types Utf8, Int32, Int64, UInt32 and UInt64.
Activity
alamb commentedon Jan 8, 2025
You could also implement this as a user defined function perhaps
HectorPascual commentedon Jan 8, 2025
Hi, thanks for the reply.
That is true, although, my concern comes from this other issue raised in delta-rs project (link below), since I need to use this hash operation in a Delta merge operation.
Unless I change the codebase for the delta-rs project, I'd be unable to create an UDF (not sure if there's a way to create and register it in the delta-rs context in python, sounds complicated)
delta-io/delta-rs#3105 (comment)
Spaarsh commentedon Jan 19, 2025
Can I take this up? I shall add the new functions in a new file in crypto/xxhas.rs similar to the crypto/sha224.rs file and import them in the crypto/mod.rs file. And then add some tests.
Do tell me if I'm missing something!
Spaarsh commentedon Jan 19, 2025
take
alamb commentedon Jan 22, 2025
@Spaarsh sounds like a good plan
ion-elgreco commentedon Jan 23, 2025
Perhaps consider adding a non cryptographic module and add wyhash as well (here some of the crates I've used for similar usecase but in polars: https://github.com/ion-elgreco/polars-hash/blob/main/polars_hash%2FCargo.toml)
Spaarsh commentedon Jan 23, 2025
Sure. I'll take a look at it and get back to you in case of any doubts! Thanks!
Spaarsh commentedon Jan 26, 2025
@HectorPascual is this the output that you expect?
xxhash32 output screenshot
xxhash64 output screenshot
HectorPascual commentedon Jan 26, 2025
Yes, that looks good!
Spaarsh commentedon Jan 27, 2025
@alamb @HectorPascual I would like to have your input on this:
I was wondering how to add support for a
Noneor empty values. Should I replace the input with "NULL" string whenever aNonevalue is entered?There is also the concern of not taking the seed from the user. Currently the seed is given a default value and I think having the user's control over it be helpful.
If we decide to ask for a seed by the user, do we keep the default to be 0? Wouldn't obfuscating that default values cause issues for the user?
I have added support for individual values of the types
Utf8,Int32,Int64,UInt32andUInt64.These are the query results:
If this is alright, then I will add the tests for these functions.
@alamb should I open a new issue for adding wyhash and the other functions? Or they can be added along with this PR?
HectorPascual commentedon Jan 27, 2025
Looks good, I can try tomorrow hashing the same inputs with the Python xxhash module and double check the output of the results. @Spaarsh
Let me gather some feedback from colleagues on your open concerns and come back later with details.
HectorPascual commentedon Jan 29, 2025
Hi @Spaarsh,
The hashes match to the python module :
In regards to your inputs :
You can for instance replace None with '' (empty string)
2-3. On the seed side, for the python module the default seed is 0, see : https://github.com/ifduyue/python-xxhash#:~:text=An%20optional%20seed%20(default%20is%200)%20can%20be%20used%20to%20alter%20the%20result%20predictably%3A
Is there an option to have this as an optional argument?
Thanks!
Spaarsh commentedon Jan 30, 2025
Thanks @HectorPascual! I'm opening PR from here on for transperancy's sake!
Spaarsh commentedon Feb 4, 2025
@HectorPascual I have added an optional seed argument and have also added support for Binary input.
Standing-Man commentedon Aug 1, 2025
Hi @Spaarsh, I'm interested in this issue. May I give it a try?
danielgafni commentedon Dec 10, 2025
Hey, is anyone working on this?
I really need
xxhash(and others) in DataFusion (I would especially love to use it from LanceDB which builds on top of DataFusion).I nobody is actively working on this issue I might give it a try.
Spaarsh commentedon Dec 11, 2025
Sure @danielgafni! Please go ahead. I request the maintainers to unassign this issue from me.
andygrove commentedon Jan 3, 2026
There is a PR to add a Spark-compatible implementation of xxhash64: #19627