4paradigm / 4paradigm/OpenMLDB
SQL function: `FirstValue` and `LastValue`
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 331
- Avg merge
- 12d 12h
- Merged PRs (30d)
- 1
Description
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
## first_value
`first_value(expr[, isIgnoreNull]) `
- Returns the first value of expr for a group of rows. If isIgnoreNull is true, returns only non-null values.
### Examples:
```SQL
> SELECT first_value(col) FROM VALUES (10), (5), (20) AS tab(col);
10
> SELECT first_value(col) FROM VALUES (NULL), (5), (20) AS tab(col);
NULL
> SELECT first_value(col, true) FROM VALUES (NULL), (5), (20) AS tab(col);
5
```
### Note:
The function is non-deterministic because its results depends on the order of the rows which may be non-deterministic after a shuffle.
## last_value
l`ast_value(expr[, isIgnoreNull])`
- Returns the last value of expr for a group of rows. If isIgnoreNull is true, returns only non-null values
### Examples:
```SQL
> SELECT last_value(col) FROM VALUES (10), (5), (20) AS tab(col);
20
> SELECT last_value(col) FROM VALUES (10), (5), (NULL) AS tab(col);
NULL
> SELECT last_value(col, true) FROM VALUES (10), (5), (NULL) AS tab(col);
5
```
### Note:
The function is non-deterministic because its results depends on the order of the rows which may be non-deterministic after a shuffle.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
目前HybridSE的在线数据是默认倒序的。在获取firstvalue和lastvalue需要特别关注这个问题
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
Contributor guide
Assessment
This issue has not been assessed yet.