Update Aggregate Key Tables through Loading
When using the VeloDB Cloud Aggregate Key Model, you typically encounter the following scenarios:
- You need to keep writing new data into an aggregate table, and you want the new values to be merged with the historical values according to the aggregation rules.
- You need to update only some columns while keeping the historical aggregate results of the other columns.
This document describes the two update methods that the VeloDB Cloud Aggregate model supports for these scenarios: whole-row updates and partial-column updates.
Compare aggregate update methods
| Update method | Applicable scenario | Supported load methods | Behavior |
|---|---|---|---|
| Whole-row update | Write a complete row, and merge the new and old values according to each column's aggregate function | Stream Load, Broker Load, Routine Load, INSERT INTO, and others | The new value and the old value are combined by the aggregate function to produce a new aggregate value |
| Partial-column update | Update only some columns while the other columns retain their existing aggregate results | See Update columns in Aggregate Key tables | Only the specified columns participate in aggregate merging |
Aggregate complete rows
When you write data into the Aggregate model (Agg model) through any of the load methods that VeloDB Cloud supports, such as Stream Load, Broker Load, Routine Load, or INSERT INTO, the engine combines each new value with the existing aggregate value using the aggregate function defined on that column, and produces a new aggregate value.
The aggregate value can be produced at the following points in time:
- Merge values at load time: merged in real time during the data write.
- Merge values during asynchronous compaction: values in the selected rowsets are merged in the background.
- Merge values at query time: remaining values with the same aggregate key are combined to produce the query result.
No matter at which stage the aggregate value is produced, the result returned to the user at query time is the same.
Update selected aggregate columns
The Aggregate Key Model supports updating only some columns in the table while the other columns retain their existing aggregate results. For details on table creation, data write examples, and usage notes, see the Update columns in Aggregate Key tables document.