|
1 | 1 | # datafusion-functions-extra
|
2 | 2 |
|
3 | 3 | [](https://github.com/datafusion-contrib/datafusion-functions-extra/actions/workflows/ci.yml?query=branch%3Amain)
|
| 4 | + |
4 | 5 | <!-- [](https://crates.io/crates/datafusion-functions-extra) -->
|
5 | 6 |
|
6 | 7 | **Note:** This is not an official Apache Software Foundation release.
|
@@ -57,8 +58,29 @@ SELECT mode(time64_col) as mode_time FROM test_table;
|
57 | 58 | -- +-----------+
|
58 | 59 | -- | 03:00:00 |
|
59 | 60 | -- +-----------+
|
| 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 | + |
60 | 80 | ```
|
61 | 81 |
|
62 | 82 | ## Done
|
63 | 83 |
|
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