Commit ec31a80
authored
[fix](function)width_bucket did not enforce that the fourth argument must be a constant. (#60643)
The implementation of width_bucket requires the fourth argument to be
constant but did not enforce this; a regular column can be passed in,
however width_bucket will only use the first row.
before
```sql
mysql> SELECT k1, v1, v2, v3, width_bucket(v1, date('2023-11-18'), date('2027-11-18'), v4) AS w FROM width_bucket_test ORDER BY k1;
+------+------------+-----------+--------+------+
| k1 | v1 | v2 | v3 | w |
+------+------------+-----------+--------+------+
| 1 | 2022-11-18 | 290000 | 290000 | 0 |
| 2 | 2023-11-18 | 320000 | 320000 | 1 |
| 3 | 2024-11-18 | 399999.99 | 399999 | 1 |
| 4 | 2025-11-18 | 400000 | 400000 | 1 |
| 5 | 2026-11-18 | 470000 | 470000 | 1 |
| 6 | 2027-11-18 | 510000 | 510000 | 2 |
| 7 | 2028-11-18 | 610000 | 610000 | 2 |
| 8 | NULL | NULL | NULL | NULL |
+------+------------+-----------+--------+------+
```
now
```sql
mysql> SELECT k1, v1, v2, v3, width_bucket(v1, date('2023-11-18'), date('2027-11-18'), v4) AS w FROM width_bucket_test ORDER BY k1;
ERROR 1105 (HY000): errCode = 2, detailMessage = The fourth argument of WidthBucket must be a constant.
```1 parent a396f34 commit ec31a80
File tree
3 files changed
+20
-2
lines changed- be/src/vec/functions
- fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar
- regression-test/suites/query_p0/sql_functions/width_bucket_fuctions
3 files changed
+20
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
| 71 | + | |
73 | 72 | | |
74 | 73 | | |
75 | 74 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
77 | 90 | | |
78 | 91 | | |
79 | 92 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
97 | 103 | | |
0 commit comments