title: ClickHouse: How to delete on *AggregatingMergeTree tables from a materialized view
body: <p>Having a structure where there is a <code>base</code> table, then a materialized view <code>base_mv</code> that aggregates sending the result <code>TO</code> an <code>AggregatedMergeTree</code> table <code>base_agg_by_id</code>. Then we have a view over this final table. <code>base_unique</code>. Similarly as in this blog post](<a href="https://www.altinity.com/blog/clickhouse-continues-to-crush-time-series" rel="nofollow noreferrer">https://www.altinity.com/blog/clickhouse-continues-to-crush-time-series</a>). </p>
  
  <p>However, if I delete from <code>base</code>, I would expect the <code>base_mv</code> would trigger the mutation and then act on it, and reflected on the <code>base_agg_by_id</code>, but it doesn't. </p>
  
  <p>Is this the expected behaviour? How to <code>DELETE</code> in such a schema?</p>
  
  <p>I've <a href="https://github.com/yandex/ClickHouse/issues/2897" rel="nofollow noreferrer">seen here</a> that in MVs that keep data you can act on <code>.inner</code> tables. However in this case, since the table is from an AggregatedMergeTree and its fields are defined as functions (e.g. <code>AggregateFunction(argMax, String, DateTime)</code> ), I cannot apply a deletion via a value such as <code>ALTER base_agg_by_id DELETE WHERE field = 'myval'</code>.</p>
  
  <p>Note. For the record, we have these tables in a replicated environment using <code>Replicated*</code> engine: <code>base_d</code>, <code>base_agg_by_id_d</code>, <code>base_unique_d</code></p>