Skip to content

Commit 38a6e2d

Browse files
committed
adding doc
1 parent 9725da5 commit 38a6e2d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# datafusion-functions-extra
22

33
[![CI](https://github.com/datafusion-contrib/datafusion-functions-extra/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/datafusion-contrib/datafusion-functions-extra/actions/workflows/ci.yml?query=branch%3Amain)
4+
45
<!-- [![Crates.io](https://img.shields.io/crates/v/datafusion-functions-extra?color=green)](https://crates.io/crates/datafusion-functions-extra) -->
56

67
**Note:** This is not an official Apache Software Foundation release.
@@ -57,8 +58,29 @@ SELECT mode(time64_col) as mode_time FROM test_table;
5758
-- +-----------+
5859
-- | 03:00:00 |
5960
-- +-----------+
61+
62+
-- Get the x value associated with the maximum y value
63+
SELECT max_by(x, y) FROM VALUES (1, 10), (2, 5), (3, 15), (4, 8) as tab(x, y);
64+
-- Results in
65+
-- +---------------------+
66+
-- | max_by(tab.x,tab.y) |
67+
-- +---------------------+
68+
-- | 3 |
69+
-- +---------------------+
70+
71+
-- Get the x value associated with the minimum y value
72+
SELECT min_by(x, y) FROM VALUES (1, 10), (2, 5), (3, 15), (4, 8) as tab(x, y);
73+
-- Results in
74+
-- +---------------------+
75+
-- | min_by(tab.x,tab.y) |
76+
-- +---------------------+
77+
-- | 2 |
78+
-- +---------------------+
79+
6080
```
6181

6282
## Done
6383

64-
* [x] `mode(expression) -> scalar` - Returns the most frequent (mode) value from a column of data.
84+
- [x] `mode(expression) -> scalar` - Returns the most frequent (mode) value from a column of data.
85+
- [x] `max_by(expression1, expression2) -> scalar` - Returns the value of `expression1` associated with the maximum value of `expression2`.
86+
- [x] `min_by(expression1, expression2) -> scalar` - Returns the value of `expression1` associated with the minimum value of `expression2`.

0 commit comments

Comments
 (0)