How AtScale Handles Incremental Aggregate Builds
This document describes how AtScale handles incremental builds for different scenarios. Not all aggregates are created equal.
First Scenario
This will show different table scenarios with 1 fact + 2 dimensions. The fact table will have incremental indicators based on time dimension with a 0 grace period.
There are 4 system-defined aggregates. 2 incremental and 2 do not have incremental.
| ATSCALE.as_agg_44af312b_pttp | 2021-08-12 14:02:21.388 -0700 |
| ATSCALE.as_agg_7cc7277c_pttp | 2021-08-12 12:13:41.434 -0700 |
CREATE VIEW PETPLAN.ATSCALE."as_agg_37908021_inc" AS |
as_agg_bf5dfdb9_none |
2021-08-12 12:38:46.266 -0700 |
as_agg_607bfeab_none |
2021-08-12 12:38:46.284 -0700 |
CREATE VIEW PETPLAN.ATSCALE."as_agg_3f3e422a_inc" AS |
as_agg_be22d33c_none |
2021-08-12 12:20:48.538 -0700 |
as_agg_90af2c31_none |
2021-08-12 12:20:48.532 -0700 |
After an aggregate standard build, AtScale will review the stored aggregate max value of the incremental indicator.
SELECT |
Then, it will do an insert based on the last update date.
SELECT |
The final results after the standard build an incremental update.
The two base table has been rebuild with new aggregate table
| as_agg_828ee4ef_pttp | 2021-08-12 14:23:16.335 -0700 |
| as_agg_ad1e2a65_pttp | 2021-08-12 14:23:07.916 -0700 |
Value |
The incremental table, however is different.
CREATE VIEW PETPLAN.ATSCALE."as_agg_7b591a1b_inc" AS |
as_agg_d9015942_none |
2021-08-12 14:23:15.811 -0700 |
as_agg_607bfeab_none |
2021-08-12 12:38:46.284 -0700 |
value |
CREATE VIEW PETPLAN.ATSCALE."as_agg_c1f91aaa_inc" AS |
as_agg_6597e160_none |
2021-08-12 14:23:14.361 -0700 |
as_agg_90af2c31_none |
2021-08-12 12:20:48.532 -0700 |
value |
It retained the hold historical aggregate + new last build data.
Alternate Scenario
Dimension values have been updated, and new dimensions have been added.
As predicted, the data that contains dimensions will be a full build, but the aggregate that is using keypair value still utilizes the incremental process.
CREATE VIEW PETPLAN.ATSCALE."as_agg_5ae949c8_inc" AS |
as_agg_90af2c31_none |
2021-08-12 12:20:48.532 -0700 |
as_agg_cb6d2da6_none |
2021-08-12 15:53:39.565 -0700 |
Keypair value data can be incremental because during runtime, atscale will do a join between fact to a dimension table based on keypair value.
SELECT |
Summary
In summary, when the system defines aggregate, it identifies that the aggregate table is using key join between fact to dimension.
The aggregate will store the join key in the aggregate table.
But if the aggregate is creating a denormalized table (storing a string value in the aggregate)
The value in the aggregate is stored as the literal string value of the dimension.
AtScale would indicate that this aggregate is a non-incremental table.
Only when you enable then, every aggregate table in AtScale will be incremental. But this could cause a problem when you have a different dataset in the aggregate table.
Using standard build
20180907 BAD_DOG BAD_DOG 29486801 0 2131 |
Full Build
20180907 BAD_DOG BAD_DOG 29486801 0 2131 |
We hope this explains how AtScale handles incremental aggregate builds.