6
6
7
7
class Window_spec ;
8
8
9
+ /*
10
+ ROW_NUMBER() OVER (...)
11
+
12
+ - This is a Window function (not just an aggregate)
13
+ - It can be computed by doing one pass over select output, provided
14
+ the output is sorted according to the window definition.
15
+ */
9
16
10
17
class Item_sum_row_number : public Item_sum_int
11
18
{
@@ -31,12 +38,28 @@ class Item_sum_row_number: public Item_sum_int
31
38
32
39
};
33
40
41
+
42
+ /*
43
+ RANK() OVER (...) Windowing function
44
+
45
+ - This is a Window function (not just an aggregate)
46
+ - It can be computed by doing one pass over select output, provided
47
+ the output is sorted according to the window definition.
48
+ */
49
+
34
50
class Item_sum_rank : public Item_sum_int
35
51
{
36
52
longlong rank;
37
-
38
- void clear () {}
39
- bool add () { return false ; }
53
+
54
+ /* TODO: implementation is currently missing */
55
+ void clear ()
56
+ {
57
+ // This is called on next partition
58
+ }
59
+ bool add ()
60
+ {
61
+ return false ;
62
+ }
40
63
void update_field () {}
41
64
42
65
public:
@@ -55,10 +78,20 @@ class Item_sum_rank: public Item_sum_int
55
78
56
79
};
57
80
81
+
82
+ /*
83
+ RANK() OVER (...) Windowing function
84
+
85
+ - This is a Window function (not just an aggregate)
86
+ - It can be computed by doing one pass over select output, provided
87
+ the output is sorted according to the window definition.
88
+ */
89
+
58
90
class Item_sum_dense_rank : public Item_sum_int
59
91
{
60
92
longlong dense_rank;
61
-
93
+
94
+ /* TODO: implementation is missing */
62
95
void clear () {}
63
96
bool add () { return false ; }
64
97
void update_field () {}
@@ -164,7 +197,7 @@ class Item_window_func : public Item_result_field
164
197
enum Item::Type type () const { return Item::WINDOW_FUNC_ITEM; }
165
198
166
199
/*
167
- TODO: Window functions are very special functions, so val_() methods have
200
+ Window functions are very special functions, so val_() methods have
168
201
special meaning for them:
169
202
170
203
- Phase#1: we run the join and put its result into temporary table. For
@@ -179,6 +212,7 @@ class Item_window_func : public Item_result_field
179
212
- Phase#3: the temporary table is read and passed to query output.
180
213
However, Item_window_func still remains in the select list, so
181
214
item_windowfunc->val_int() will be called.
215
+ During Phase#3, read_value_from_result_field= true.
182
216
*/
183
217
private:
184
218
bool read_value_from_result_field;
0 commit comments