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
SELECT
"table_union"."key_c1" AS "key_c1",
"table_union"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"table_union"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"table_union"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
(
SELECT
"as_agg_bf5dfdb9_none"."key_c1" AS "key_c1",
"as_agg_bf5dfdb9_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_bf5dfdb9_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_bf5dfdb9_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_bf5dfdb9_none"
UNION ALL
SELECT
"as_agg_607bfeab_none"."key_c1" AS "key_c1",
"as_agg_607bfeab_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_607bfeab_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_607bfeab_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_607bfeab_none"
) AS "table_union";
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
SELECT
"table_union"."key_c1" AS "key_c1",
"table_union"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"table_union"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"table_union"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
(
SELECT
"as_agg_be22d33c_none"."key_c1" AS "key_c1",
"as_agg_be22d33c_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_be22d33c_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_be22d33c_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_be22d33c_none"
UNION ALL
SELECT
"as_agg_90af2c31_none"."key_c1" AS "key_c1",
"as_agg_90af2c31_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_90af2c31_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_90af2c31_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_90af2c31_none"
) AS "table_union";
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
MAX(CAST("t_13"."date_sk_c12" AS DECIMAL(38,0))) AS "c_16"
FROM
(
SELECT
"fact_inc_t11"."DATE_SK" AS "date_sk_c12"
FROM
"PETPLAN"."FACT"."FACT_INC" AS "fact_inc_t11"
WHERE
CAST("fact_inc_t11"."DATE_SK" AS DECIMAL(38,0)) >= 20180614
GROUP BY
1
) AS "t_13"
WHERE
true
Then, it will do an insert based on the last update date.
SELECT
"t_31"."rawpolicyid_c30" AS "key_c1",
SUM("t_31"."inforceamt_c28") AS "m_inforceamt_sum_c2",
MIN("t_31"."inforceamt_c28") AS "m_inforceamt_sum_c3",
MAX("t_31"."inforceamt_c28") AS "m_inforceamt_sum_c4"
FROM
(
SELECT
"fact_inc_t27"."DATE_SK" AS "date_sk_c29",
"fact_inc_t27"."INFORCEAMT" AS "inforceamt_c28",
"fact_inc_t27"."RAWPOLICYID" AS "rawpolicyid_c30"
FROM
"PETPLAN"."FACT"."FACT_INC" AS "fact_inc_t27"
WHERE
"fact_inc_t27"."DATE_SK" <= 20180614
AND
"fact_inc_t27"."DATE_SK" >= 20180614
) AS "t_31"
WHERE
true
GROUP BY
1
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
20180306DogDog2656958702122
20180306CatCat36517460913
Value
DogDog5519735002131
CatCat75344550913
The incremental table, however is different.
CREATE VIEW PETPLAN.ATSCALE."as_agg_7b591a1b_inc" AS
SELECT
"table_union"."key_c1" AS "key_c1",
"table_union"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"table_union"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"table_union"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
(
SELECT
"as_agg_d9015942_none"."key_c1" AS "key_c1",
"as_agg_d9015942_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_d9015942_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_d9015942_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_d9015942_none"
UNION ALL
SELECT
"as_agg_607bfeab_none"."key_c1" AS "key_c1",
"as_agg_607bfeab_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_607bfeab_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_607bfeab_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_607bfeab_none"
) AS "table_union";
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
201806143251047202131
CREATE VIEW PETPLAN.ATSCALE."as_agg_c1f91aaa_inc" AS
SELECT
"table_union"."key_c1" AS "key_c1",
"table_union"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"table_union"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"table_union"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
(
SELECT
"as_agg_6597e160_none"."key_c1" AS "key_c1",
"as_agg_6597e160_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_6597e160_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_6597e160_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_6597e160_none"
UNION ALL
SELECT
"as_agg_90af2c31_none"."key_c1" AS "key_c1",
"as_agg_90af2c31_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_90af2c31_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_90af2c31_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_90af2c31_none"
) AS "table_union";
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
1068444000
49380137137137
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
SELECT
"table_union"."key_c1" AS "key_c1",
"table_union"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"table_union"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"table_union"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
(
SELECT
"as_agg_cb6d2da6_none"."key_c1" AS "key_c1",
"as_agg_cb6d2da6_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_cb6d2da6_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_cb6d2da6_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_cb6d2da6_none"
UNION ALL
SELECT
"as_agg_90af2c31_none"."key_c1" AS "key_c1",
"as_agg_90af2c31_none"."m_inforceamt_sum_c2" AS "m_inforceamt_sum_c2",
"as_agg_90af2c31_none"."m_inforceamt_sum_c3" AS "m_inforceamt_sum_c3",
"as_agg_90af2c31_none"."m_inforceamt_sum_c4" AS "m_inforceamt_sum_c4"
FROM
"PETPLAN"."ATSCALE"."as_agg_90af2c31_none"
) AS "table_union";
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
"t_19"."policy_gbakc2" AS "policy",
"t_19"."sum_m_inforceamt_s_gbakc3" AS "sum_m_inforceamt_sum_ok"
FROM
(
SELECT
"t_17"."policydisplaynumbe_c16" AS "policy_gbakc2",
SUM("as_agg_3f3e422a_in_t13"."m_inforceamt_sum_c2") AS "sum_m_inforceamt_s_gbakc3",
"t_17"."rawpolicyid_c15" AS "policy_gbakc1"
FROM
"PETPLAN"."ATSCALE"."as_agg_3f3e422a_inc" AS "as_agg_3f3e422a_in_t13"
JOIN (
SELECT
"policy_inc_t14"."POLICYDISPLAYNUMBER" AS "policydisplaynumbe_c16",
"policy_inc_t14"."RAWPOLICYID" AS "rawpolicyid_c15"
FROM
"PETPLAN"."DIM"."POLICY_INC" AS "policy_inc_t14"
WHERE
true
GROUP BY
1,
2
) AS "t_17" ON "as_agg_3f3e422a_in_t13"."key_c1" = "t_17"."rawpolicyid_c15"
WHERE
true
GROUP BY
1,
3
) AS "t_19"
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
20180907BAD_DOGBAD_DOG2948680102131
20180907NEW_CATNEW_CAT39624550958
20180614NEW_CATNEW_CAT38827090913
20180614BAD_DOGBAD_DOG2862776302131
20180306NEW_CATNEW_CAT36517460913
20180309NEW_CATNEW_CAT36875580913
20180309NEW_DOGNEW_DOG2684294502122
20180307NEW_DOGNEW_DOG2665753302122
20180306NEW_DOGNEW_DOG2656958702122
20180307NEW_CATNEW_CAT36668080913
Full Build
20180907BAD_DOGBAD_DOG2948680102131
20180614NEW_CATNEW_CAT38827090913
20180306NEW_CATNEW_CAT36517460913
20180309NEW_CATNEW_CAT36875580913
20180309BAD_DOGBAD_DOG2684294502122
20180614BAD_DOGBAD_DOG2862776302131
20180306BAD_DOGBAD_DOG2656958702122
20180907NEW_CATNEW_CAT39624550958
20180307BAD_DOGBAD_DOG2665753302122
20180307NEW_CATNEW_CAT36668080913
We hope this explains how AtScale handles incremental aggregate builds.
Was this article helpful?
0 out of 0 found this helpful
Popular Searches
<% var getColumnClasses = function(numberColumns) {
var classNames = 'col-12';
if (numberColumns >= 2) classNames += ' md:col-6';
if (numberColumns >= 3) classNames += ' lg:col-4';
if (numberColumns >= 4) classNames += ' xl:col-3';
return classNames;
} %>