-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support sha2 and sha2_hex with digest size of 256 #63
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, thank you for this!
.transform(values_columns) | ||
.sql() | ||
== "INSERT INTO table1 (name) SELECT SHA2_HEX('foo', 256, 'wtf')" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind also adding a test to test_fakes.py too? this will guarantee integrated test coverage that includes duckdb's execution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added now, thanks
1c6f51f
to
291e661
Compare
291e661
to
eb8d843
Compare
62b8f1d
to
321677a
Compare
I realised I could use duckdb doesn't have that function but In [24]: duckdb.sql("SELECT unhex(sha256('Snowflake'))").show()
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ unhex(sha256('Snowflake')) │
│ blob │
├────────────────────────────────────────────────────────────────────────────────────────┤
│ \x1D\xBDY\xF6a\xD6\x8B\x90rO!\x08C\x96\xB8eIqs\xE4\xD2qOM\x91\xCF\x05\xFA_\xC5\xE1\x8D │
└────────────────────────────────────────────────────────────────────────────────────────┘
In [25]: sha256(b"Snowflake").digest()
Out[25]: b'\x1d\xbdY\xf6a\xd6\x8b\x90rO!\x08C\x96\xb8eIqs\xe4\xd2qOM\x91\xcf\x05\xfa_\xc5\xe1\x8d' so I have added that transform as well |
Perfect, thank you! |
We're using Snowflake
sha2
function in our project that usesfakesnow
for testing (it's great, thank you!)But duckdb does not have
sha2
function, instead it has asha256
functionsha256(foo)
is the same as Snowflakesha2('foo', 256)
(or you can omit the length arg and it defaults to 256) https://docs.snowflake.com/en/sql-reference/functions/sha2#argumentsSo this PR adds a transform for these function calls