Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ pbjson-types = "0.8"
# Should match arrow-flight's version of prost.
prost = "0.14.1"
rand = "0.9"
rand_distr = "0.5.1"
recursive = "0.1.1"
regex = "1.12"
rstest = "0.26.1"
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ glob = { workspace = true }
insta = { workspace = true }
paste = { workspace = true }
rand = { workspace = true, features = ["small_rng"] }
rand_distr = "0.5"
rand_distr = { workspace = true }
recursive = { workspace = true }
regex = { workspace = true }
rstest = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions datafusion/spark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ datafusion-functions-nested = { workspace = true }
log = { workspace = true }
percent-encoding = "2.3.2"
rand = { workspace = true }
rand_distr = { workspace = true }
sha1 = "0.10"
url = { workspace = true }

Expand Down
29 changes: 29 additions & 0 deletions datafusion/spark/src/function/math/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod expm1;
pub mod factorial;
pub mod hex;
pub mod modulus;
pub mod random;
pub mod rint;
pub mod trigonometry;
pub mod width_bucket;
Expand All @@ -34,7 +35,11 @@ make_udf_function!(factorial::SparkFactorial, factorial);
make_udf_function!(hex::SparkHex, hex);
make_udf_function!(modulus::SparkMod, modulus);
make_udf_function!(modulus::SparkPmod, pmod);
make_udf_function!(random::SparkRandom, random);
make_udf_function!(random::SparkRandN, randn);
make_udf_function!(random::SparkRandStr, randstr);
make_udf_function!(rint::SparkRint, rint);
make_udf_function!(random::SparkUniform, uniform);
make_udf_function!(width_bucket::SparkWidthBucket, width_bucket);
make_udf_function!(trigonometry::SparkCsc, csc);
make_udf_function!(trigonometry::SparkSec, sec);
Expand All @@ -60,6 +65,26 @@ pub mod expr_fn {
export_functions!((width_bucket, "Returns the bucket number into which the value of this expression would fall after being evaluated.", arg1 arg2 arg3 arg4));
export_functions!((csc, "Returns the cosecant of expr.", arg1));
export_functions!((sec, "Returns the secant of expr.", arg1));
export_functions!((
random,
"Returns a random float value sampled from a uniform distribution in [0, 1).",
opt_seed
));
export_functions!((
randn,
"Returns a random float value sampled from the standard normal distribution.",
opt_seed
));
export_functions!((
randstr,
"Returns a random string of the specified length.",
length opt_seed
));
export_functions!((
uniform,
"Returns a random float value sampled from a uniform distribution in [`min`, `max`).",
min max opt_seed
));
}

pub fn functions() -> Vec<Arc<ScalarUDF>> {
Expand All @@ -74,5 +99,9 @@ pub fn functions() -> Vec<Arc<ScalarUDF>> {
width_bucket(),
csc(),
sec(),
random(),
randn(),
randstr(),
uniform(),
]
}
Loading