Many data analytics use-cases only need aggregated data. For example, data used in charts can be aggregated down to one row per time bucket per dimension combination.
Doing this results in much less storage and better query performance. Configuring this for a table is done via the Aggregation Config in the table config.
The aggregation config controls the aggregations that happen during real-time data ingestion. Offline aggregations must be handled separately.
Below is a description of the config, which is defined in the ingestion config of the table config.
The following are required for ingestion aggregation to work:
Ingestion aggregation config is effective only for real-time tables. (There is no ingestion time aggregation support for offline tables. We need use Merge/Rollup Task or pre-process aggregations in the offline data flow using batch processing engines like Spark/MapReduce).
Stream ingestion type must be lowLevel.
All metrics must have aggregation configs.
All metrics must be noDictionaryColumns.
aggregatedFieldName
must be in the Pinot schema and originalFieldName
must not exist in Pinot schema
Here is an example of sales data, where only the daily sales aggregates per product are needed.
Note that the schema only reflects the final table structure.
From the below aggregation config example, note that price
exists in the input data while total_sales
exists in the Pinot Schema.
Startrees can only be added to real-time segments after the segments has sealed, and creating startrees is CPU-intensive. Ingestion Aggregation works for consuming segments and uses no additional CPU.
Startrees take additional memory to store, while ingestion aggregation stores less data than the original dataset.
If the original rows in non-aggregated form are needed, then ingestion-aggregation cannot be used.
aggregateMetrics
setting?The aggregateMetrics
works the same as Ingestion Aggregation, but only allows for the SUM function.
The current changes are backward compatible, so no need to change your table config unless you need a different aggregation function.
Ingestion Aggregation only works for real-time ingestion. For offline data, the offline process needs to generate the aggregates separately.
If a metric isn't aggregated then it will result in more than one row per unique set of dimensions.
product_name | sales_count | total_sales | daysSinceEpoch |
---|---|---|---|
function name | notes |
---|---|
car
2
2800.00
18193
truck
1
2200.00
18193
truck
1
700.00
18199
car
2
3300.00
18200
truck
1
800.00
18202
car
3
3700.00
18202
MAX
MIN
SUM
COUNT
Specify as COUNT(*)
DISTINCTCOUNTHLL
Specify as DISTINCTCOUNTHLL(field, log2m)
, default is 12. See function reference for how to define log2m
. Cannot be changed later, a new field must be used. The schema for the output field should be BYTES
type.
DISTINCTCOUNTHLLPLUS
Specify as DISTINCTCOUNTHLLPLUS(field, s, p)
. See function reference for how to define s
and p
, they cannot be changed later. The schema for the output field should be BYTES
type.
SUMPRECISION
Specify as SUMPRECISION(field, precision)
, precision must be defined. Used to compute the maximum possible size of the field. Cannot be changed later, a new field must be used. The schema for the output field should be BIG_DECIMAL
type.