Conversion

RisingWave converts well-known types from the protobuf library to specific types in RisingWave. The conversion is as follows:

Protobuf typeRisingWave type
anyjsonb
doubledouble precision
floatreal
int32int
int64bigint
uint32bigint
uint64decimal
sint32int
sint64bigint
fixed32bigint
fixed64decimal
sfixed32int
sfixed64bigint
boolboolean
stringvarchar
bytesbytea
enumvarchar
messagestruct. See details in Nested messages.
messages_as_jsonbjsonb. See details in Handle recursive definitions.
repeatedarray
mapmap. See details in Map.
google.protobuf.StructNot supported
google.protobuf.Timestampstruct<seconds bigint, nanos int>
google.protobuf.Durationstruct<seconds bigint, nanos int>
google.protobuf.Anystruct<type_url varchar, value bytea>
google.protobuf.Int32Valuestruct<value int>
google.protobuf.StringValuestruct<value varchar>

Nested messages

The nested fields are transformed into columns within a struct type. For example, a Protobuf message with the following structure:

message NestedMessage {
  int32 id = 1;
  string name = 2;
}

Will be converted to struct<id int, name varchar> in RisingWave.

Handle recursive definitions

When detecting a recursive definition in the protobuf, RisingWave will reject the statement and show the circular dependency. Adding dependency items to messages_as_jsonb with full type name separated by comma can solve the case. For example:

CREATE TABLE opentelemetry_test 
WITH ( 
    ${RISEDEV_KAFKA_WITH_OPTIONS_COMMON}, 
    topic = 'opentelemetry_test' 
) 
FORMAT PLAIN 
ENCODE PROTOBUF ( 
    schema.registry = '${RISEDEV_SCHEMA_REGISTRY_URL}', 
    message = 'opentelemetry_test.OTLPTestMessage', 
    messages_as_jsonb = 'opentelemetry.proto.common.v1.ArrayValue,opentelemetry.proto.common.v1.KeyValueList,opentelemetry.proto.common.v1.AnyValue'
);