4paradigm / 4paradigm/OpenMLDB

When ts=0, the calculation of history window is wrong

Đang mở
#2,214 0 bình luận 0 reaction 1 người được giao Được @aceforeverd nhận Xem trên GitHub
bug execute-engine
Ngôn ngữ chính
C++
Star
1.7k
Fork
331
Merge trung bình
12 ngày 12 giờ
Pull request đã merge (30 ngày)
1

Mô tả

**Bug Description**
When ts=0, the calculation of history window is wrong.
+ case
```yaml
- id: 32
desc: rows_range-纯历史窗口-current_row-ts=0
inputs:
- columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ]
indexs: [ "index1:c1:c7" ]
rows:
- [ "aa",20,30,1.1,2.1,0,"2020-05-01" ]
- [ "aa",21,31,1.2,2.2,0,"2020-05-02" ]
- [ "aa",22,32,1.3,2.3,1000,"2020-05-03" ]
- [ "aa",23,33,1.4,2.4,2000,"2020-05-04" ]
- [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ]
sql: |
SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 1s PRECEDING EXCLUDE CURRENT_ROW);
expect:
order: c3
columns: [ "c1 string","c3 int","w1_c4_sum bigint" ]
rows:
- [ "aa",20,null ]
- [ "aa",21,null ]
- [ "aa",22,61 ]
- [ "aa",23,93 ]
- [ "bb",24,null ]
```

**Expected Behavior**
![image](https://user-images.githubusercontent.com/18275570/180157948-153e5b2f-bcfa-42a4-b815-ce4d7b645d18.png)

**Relation Case**
test_current_row.yaml id:32

**Steps to Reproduce**

1.
2.
3.
4.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

The bug is in the calculation of the history window when timestamp (ts) is 0, as shown in the YAML test case. Look at the window function logic in the codebase, likely in the SQL engine or window computation module. The test case 'test_current_row.yaml id:32' is the failing test; run it to reproduce the issue. Investigate how timestamps of zero are handled in the rows_range window frame, particularly for the '2s PRECEDING AND 1s PRECEDING EXCLUDE CURRENT_ROW' clause.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
sql
Lĩnh vực
databases, machine-learning
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.