title: Clickhouse altering materialized view's select
body: <p>I have following setup:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS request_income_buffer (
      timestamp UInt64,
      timestamp_micro Float32,
      traceId Int64,
      host String,
      type String,
      service String,
      message String,
      caller String,
      context String
  ) ENGINE = Kafka('kafka:9092', 'request_income', 'group', 'JSONEachRow');
  
  CREATE MATERIALIZED VIEW IF NOT EXISTS request_income
  ENGINE = MergeTree(date, microtime, 8192) AS
      SELECT
          toDate(toDateTime(timestamp)) AS `date`,
          toDateTime(timestamp) as `date_time`,
          timestamp,
          timestamp_micro AS `microtime`,
          traceId,
          host,
          type,
          service,
          message,
          caller,
          context
      FROM
          request_income_buffer;
  </code></pre>
  
  <p>I want to add new column, ex. <code>ip</code> to <code>my request_income</code> table. 
  According to docs in order to do so I will need to follow next steps:</p>
  
  <ol>
  <li><p>Detach view to stop receiving messages from Kafka. </p>
  
  <blockquote>
    <p>DETACH TABLE request_income;</p>
  </blockquote></li>
  <li><p>Drop table that streams data from Kafka since Kafka engine doesn't support <code>ALTER</code> queries.</p>
  
  <blockquote>
    <p>DROP TABLE request_income_buffer</p>
  </blockquote></li>
  <li><p>Recreate table that streams data from Kafka with new field.</p>
  
  <blockquote>
    <p>CREATE TABLE IF NOT EXISTS request_income_buffer (
    timestamp UInt64,
    timestamp_micro Float32,
    traceId Int64,
    host String,
    ip String,
    type String,
    service String,
    message String,
    caller String,
    context String
    ) ENGINE = Kafka('kafka:9092', 'request_income', 'group', 'JSONEachRow');</p>
  </blockquote></li>
  <li><p>According to this <a href="https://github.com/yandex/ClickHouse/issues/1226" rel="noreferrer">post</a> update .inner table of the detached materialized view </p>
  
  <blockquote>
    <p>ALTER TABLE `.inner.request_income` ADD COLUMN ip String AFTER host;</p>
  </blockquote></li>
  <li><p>According to post from above update view's select query </p></li>
  <li>Attach view 
  
  <blockquote>
    <p>ATTACH TABLE request_income</p>
  </blockquote></li>
  </ol>
  
  <p>Question is how to update view's select query?</p>