Skip to content

Conversation

@Jefffrey
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Simplify implementation, also remove usage of user_defined.

What changes are included in this PR?

Refactor to be simpler.

Are these changes tested?

Added tests.

Are there any user-facing changes?

No.

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation spark labels Dec 24, 2025
Comment on lines -49 to +63
signature: Signature::user_defined(Volatility::Immutable),
aliases: vec![],
signature: Signature::coercible(
vec![
Coercion::new_implicit(
TypeSignatureClass::Native(logical_binary()),
vec![TypeSignatureClass::Native(logical_string())],
NativeType::Binary,
),
Coercion::new_implicit(
TypeSignatureClass::Native(logical_int32()),
vec![TypeSignatureClass::Integer],
NativeType::Int32,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving away from user_defined; also we cast strings to binary to simplify implementation as we only need raw bytes either way

Comment on lines +121 to +134
let mut digest = sha2::Sha224::default();
digest.update(value);
Some(hex_encode(digest.finalize()))
}
(Some(value), Some(0 | 256)) => {
let mut digest = sha2::Sha256::default();
digest.update(value);
Some(hex_encode(digest.finalize()))
}
(Some(value), Some(384)) => {
let mut digest = sha2::Sha384::default();
digest.update(value);
Some(hex_encode(digest.finalize()))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We directly use the sha2 crate to do the hashing now; previously we used functions exposed by datafusion-functions but that seemed like unnecessary indirection

regex = "1.12"
rstest = "0.26.1"
serde_json = "1"
sha2 = "^0.10.9"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because datafusion-spark now uses sha2 directly, we extract it as a common dependency

@Jefffrey Jefffrey marked this pull request as ready for review December 24, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation spark sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant