跳转到主内容
跳转到主内容

ProtobufList

Not supported in ClickHouse Cloud
输入输出别名

描述

ProtobufList 格式与 Protobuf 格式类似,但每一行表示为一系列子消息,这些子消息包含在一个名称固定为 "Envelope" 的消息中。

示例用法

例如:

SELECT * FROM test.table FORMAT ProtobufList SETTINGS format_schema = 'schemafile:MessageType'
cat protobuflist_messages.bin | clickhouse-client --query "INSERT INTO test.table FORMAT ProtobufList SETTINGS format_schema='schemafile:MessageType'"

其中 schemafile.proto 文件内容如下:

syntax = "proto3";
message Envelope {
  message MessageType {
    string name = 1;
    string surname = 2;
    uint32 birthDate = 3;
    repeated string phoneNumbers = 4;
  };
  MessageType row = 1;
};

format_schema 中指定的消息类型会先解析为顶层 Envelope 消息内部的嵌套类型。如果未找到匹配项——无论是因为 schema 中没有 Envelope 消息,还是因为 Envelope 中不包含具有所请求名称的消息——则直接使用该名称对应的顶层消息。

格式设置