title: Query/flatten a serialized protobuf stored as a string column in Clickhouse
body: <p><strong>TLDR</strong></p>
  <p>I have a column of serialized protobufs in a table in Clickhouse, and I would like to flatten those protobufs into another table via a materialized view. How do I format the materialized view to do this?</p>
  <p><strong>Details</strong></p>
  <p>I have a RabbitMQ queue which serves messages to my Clickhouse server. The message <code>outer.proto</code> consists of a service name and a serialized protobuf message payload:</p>
  <pre><code>//outer.proto
  syntax = &quot;proto2&quot;
  
  message WrappedMessage {
      required string svc_id = 1;
      required bytes     msg = 2;
  }
  </code></pre>
  <p>This service name and payload are then stored in Clickhouse as such:</p>
  <pre><code>CREATE TABLE raw_records_rmq
  (
      svc_id String NOT NULL
      , msg String NOT NULL
  ) ENGINE = RabbitMQ SETTINGS
    --skip rabbitmq settings, this part works
    rabbitmq_format='ProtobufSingle'
    rabbitmq_schema = 'outer:WrappedMessage'
  ;
  
  CREATE TABLE raw_records
  (
      svc_id String NOT NULL
      , msg String NOT NULL
  ) ENGINE = MergeTree ORDER BY tuple()
  ;
  
  CREATE MATERIALIZED VIEW raw_mv 
  TO raw_records AS
  SELECT * FROM raw_records_rmq
  </code></pre>
  <p>This process works as expected, with the serialized message stored in <code>raw_records.msg</code>. The message is defined as such:</p>
  <pre><code>//inner.proto
  syntax = &quot;proto2&quot;
  
  message Person {
      optional uint32       id = 1;
      optional string     name = 2;
      optional bool   arb_bool = 3;
  }
  </code></pre>
  <p>I would now like to query the contents of the stored message; to simplify this, I create a destination table:</p>
  <pre><code>CREATE TABLE people 
  (
      id UInt32
      , name String
      , arb_bool UInt8
  ) ENGINE = MergeTree ORDER BY tuple()
  </code></pre>
  <p>But this is where my success stops. My attempts so far have been to query the column as a subquery and then attempt to parse the results as protobufs using Clickhouse <code>FORMAT</code> and <code>SETTINGS</code>, as described in their documentation:</p>
  <pre><code>CREATE MATERIALIZED VIEW mv 
  TO people AS
  SELECT * FROM (SELECT proto FROM raw_records) 
  FORMAT ProtobufSingle 
  SETTINGS format_schema='inner:Person'
  </code></pre>
  <p>However, this fails to unpack the protobuf message. Changing from a Materialized View to a standard View shows that Clickhouse is returning only the single column specified in the subquery with the entire protobuf message as each result.</p>
  <p>Any advice on how to properly format this materialized view, or alternatives for processing protobufs-inside-protobufs would be greatly appreciated!</p>