You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -106,7 +103,7 @@ public class WeightedAvg implements AggregateFunction {
106
103
// Get the aggregate result.
107
104
// The result type is inferred from the signature. (BIGINT)
108
105
// If a Java type can not infer to an unique SQL type, it should be annotated with `@DataTypeHint`.
109
-
publicLonggetValue(WeightedAvgStateacc) {
106
+
publicLonggetResult(WeightedAvgStateacc) {
110
107
if (acc.count ==0) {
111
108
returnnull;
112
109
} else {
@@ -152,7 +149,7 @@ The full syntax is:
152
149
153
150
```sql
154
151
CREATE [ OR REPLACE ] AGGREGATE name ( [ argname ] arg_data_type [ , ... ] )
155
-
[ RETURNS return_data_type ] [ APPEND ONLY ]
152
+
[ RETURNS result_data_type ] [ APPEND ONLY ]
156
153
[ LANGUAGE language ] [ AS identifier ] [ USING LINK link ];
157
154
```
158
155
@@ -206,9 +203,9 @@ sequenceDiagram
206
203
207
204
The state of UDAF is managed by the compute node as a single encoded BYTEA value.
208
205
209
-
Currently, each aggregate operator has a **result table** to store the aggregate result. For most of our built-in aggregate functions, they have the same output as their state, so the result table is actually being used as the state table. However, for general UDAFs, their state may not be the same as their output. Such functions are not supported for now.
206
+
Currently, each aggregate operator has a **result table** to store the aggregate result. For most of our built-in aggregate functions, they have the same output as their state, so the result table is actually being used as the **intermediate state table**. However, for general UDAFs, their state may not be the same as their output. Such functions are not supported for now.
210
207
211
-
Therefore, we propose to **transform the result table into state table**. The content of the table remains the same for existing functions. But for new functions whose state is different from output, only the state is stored. The output can be computed from the state when needed.
208
+
Therefore, we propose to **transform the result table into intermediate state table**. The content of the table remains the same for existing functions. But for new functions whose state is different from output, only the state is stored. The output can be computed from the state when needed.
212
209
213
210
For example, given the input:
214
211
@@ -218,14 +215,14 @@ For example, given the input:
218
215
| 2 | U- | 0 | 1 | 2 | false |
219
216
| 2 | U+ | 0 | 2 | 1 | true |
220
217
221
-
The new **state table** (derived from old result table) of the agg operator would be like:
218
+
The new **intermediate state table** (migrated from the old result table) of the agg operator would be like:
* For**append-only** aggregate functions (e.g. max, min, first, last, string_agg...), their states are all input values maintained in seperate "materialized input" tables. For backward compatibility, their values in the state table are still aggregate results.
225
+
Note: for**append-only** aggregate functions (e.g. max, min, first, last, string_agg...), their states are all input values maintained in seperate "materialized input" tables. For backward compatibility, their values in the state table are still aggregate results.
0 commit comments