User defined aggregate functions
- Dominant language
- Python
- Stars
- 38
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Taken from [Spectrum](https://spectrum.chat/edgedb/general/feature-request-reduce-operator-in-edgeql~78e141dd-c63c-467b-984a-29f8a9a1d64c).
This is how i first imagined the syntax:
```
FOR accumulator, variable IN "{" iterator-set [, ...] "}"
REDUCE output-expr ;
```
Note that this doesn't allow defining arbitrary aggregate functions, but rather executing them, just like `FOR`.
### Example 1
```
FOR sentence = "", word IN { "hello", "world" }
REDUCE (
SELECT result ++ " " ++ word
)
```
This would give a result of `hello world`.
We can also access the current index by using `_index` and the original set using`_source`
```
FOR sentence = "", word IN { "hello", "world" }
REDUCE (
SELECT (
((SELECT count(_source)) ++ " ") IF _index = 1 ELSE "")
++ result ++ " " ++ word ++ " "
)
```
Result: `2 hello world`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the proposed FOR/REDUCE syntax and both examples in this RFC, including the use of _index and _source. Define the required behavior and scope from those examples; completion would require an accepted design for user-defined aggregate execution, but no implementation files or tests are named.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100