From 1342ef9683698c22aeabd113f44235a85320fe81 Mon Sep 17 00:00:00 2001 From: jatin Date: Thu, 26 Sep 2024 23:57:58 +0530 Subject: [PATCH] updated readme.md with kurtosis example --- README.md | 10 ++++++++++ src/lib.rs | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e63330..4344dae 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,15 @@ SELECT min_by(x, y) FROM VALUES (1, 10), (2, 5), (3, 15), (4, 8) as tab(x, y); -- | 2 | -- +---------------------+ +-- Get the kurtosis value of a column of numeric data. +SELECT kurtosis(col) FROM VALUES (1.0), (10.0), (100.0), (10.0), (1.0) as tab(col); +-- Results in +- +-------------------+ +- "| kurtosis(tab.col) |" +- +-------------------+ +- "| 4.777292927667962 |" +- +-------------------+ + ``` ## Done @@ -84,3 +93,4 @@ SELECT min_by(x, y) FROM VALUES (1, 10), (2, 5), (3, 15), (4, 8) as tab(x, y); - [x] `mode(expression) -> scalar` - Returns the most frequent (mode) value from a column of data. - [x] `max_by(expression1, expression2) -> scalar` - Returns the value of `expression1` associated with the maximum value of `expression2`. - [x] `min_by(expression1, expression2) -> scalar` - Returns the value of `expression1` associated with the minimum value of `expression2`. +- [x] `kurtosis(expression) -> scalar` - Returns the kurtosis, a measure of the `tailedness` of the distribution, for the given numeric values in `expression`. \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index ee8f2ee..d79291c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,17 +26,24 @@ use datafusion::logical_expr::AggregateUDF; #[macro_use] pub mod macros; pub mod common; +pub mod kurtosis; pub mod max_min_by; pub mod mode; pub mod expr_extra_fn { + pub use super::kurtosis::kurtosis; pub use super::max_min_by::max_by; pub use super::max_min_by::min_by; pub use super::mode::mode; } pub fn all_extra_aggregate_functions() -> Vec> { - vec![mode_udaf(), max_min_by::max_by_udaf(), max_min_by::min_by_udaf(), kurtosis::kurtosis_udaf()] + vec![ + mode_udaf(), + max_min_by::max_by_udaf(), + max_min_by::min_by_udaf(), + kurtosis::kurtosis_udaf(), + ] } /// Registers all enabled packages with a [`FunctionRegistry`]