4paradigm / 4paradigm/OpenMLDB
lag correctness: wrong result used as parameter of other udaf
- Vorherrschende Sprache
- C++
- Sterne
- 1.7k
- Forks
- 331
- Ø Merge
- 12 T. 12 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
```yaml
- id: 66
sql: |
select
idx,
sum_where(val, val > lag(val, 1)) over w as out,
from t1
window w as (
partition by gp order by ts
rows_range between 10s preceding and 1s preceding
)
inputs:
- name: t1
columns: ["idx int", "gp int", "val int", "ts timestamp"]
indexs: ['idx:gp:ts']
data: |
100, 1, 1, 1000
200, 1, 2, 2000
300, 1, 1, 3000
400, 1, 2, 4000
expect:
columns:
- idx int
- out int32
order: idx
data: |
100, NULL
200, NULL
300, NULL
400, 2
```
`sum_where` and `lag` compute over the same history window [10s - 1s] , however does not meet the specification for `lag` (**always evaluated based on current row**).
Beitragsleitfaden
Rechercherichtung
The issue is about the lag function within a window in OpenMLDB, a C++ database for machine learning. The test case in the issue body shows the SQL query and expected output. Investigate the window function evaluation logic, likely in the SQL engine or UDAF implementation. Look for where lag is computed relative to the current row versus the window frame. Running the provided test will show the discrepancy. The fix involves ensuring lag uses the correct row context within the window.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- sql
- Bereich
- databases, machine-learning
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100