How it is done:
1. Intermediate states of aggregate functions are first-class data types in ClickHouse. You can create a data type for the intermediate state of count(distinct), or quantile, whatever, and it will store a serialized state. It can be inserted into a table, read back, merged or finalized, and processed further.
2. Materialized views are simple triggers on INSERT. It enables incremental aggregation in realtime with materialized views.
Downsides:
Limited area of application. Does not respect multi-table queries if updates are done on more than one table.
Disclaimer: I'm developer of ClickHouse: https://github.com/ClickHouse/ClickHouse