Skip to content

Add xxhash algorithms in SQL and expression api #14367

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

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions datafusion-cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions datafusion/functions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ workspace = true
# enable core functions
core_expressions = []
crypto_expressions = ["md-5", "sha2", "blake2", "blake3"]
hash_expressions = ["twox-hash"]
# enable datetime functions
datetime_expressions = []
# Enable encoding by default so the doctests work. In general don't automatically enable all packages.
Expand All @@ -46,6 +47,7 @@ default = [
"regex_expressions",
"string_expressions",
"unicode_expressions",
"hash_expressions",
]
# enable encode/decode functions
encoding_expressions = ["base64", "hex"]
Expand Down Expand Up @@ -85,6 +87,7 @@ md-5 = { version = "^0.10.0", optional = true }
rand = { workspace = true }
regex = { workspace = true, optional = true }
sha2 = { version = "^0.10.1", optional = true }
twox-hash = { version = "1.6.3", optional = true }
unicode-segmentation = { version = "^1.7.1", optional = true }
uuid = { version = "1.7", features = ["v4"], optional = true }

Expand Down
45 changes: 45 additions & 0 deletions datafusion/functions/src/hash/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

//! "xxhash" DataFusion functions

use datafusion_expr::ScalarUDF;
use std::sync::Arc;

pub mod xxhash;
make_udf_function!(xxhash::XxHash32Func, xxhash32);
make_udf_function!(xxhash::XxHash64Func, xxhash64);

pub mod expr_fn {
export_functions!(
(
xxhash32,
"Computes the XXHash32 hash of a binary string.",
input
),
(
xxhash64,
"Computes the XXHash64 hash of a binary string.",
input
)
);
}

/// Returns all DataFusion functions defined in this package
pub fn functions() -> Vec<Arc<ScalarUDF>> {
vec![xxhash32(), xxhash64()]
}
Loading
Loading