Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support google well-known-types in protobuf #10478

Closed
wants to merge 1 commit into from

Conversation

tabVersion
Copy link
Contributor

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

resolve #10443 #10475

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)

Documentation

  • My PR contains user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

@github-actions github-actions bot added the type/fix Bug fix label Jun 21, 2023
@tabVersion
Copy link
Contributor Author

tabVersion commented Jun 21, 2023

any idea on how to parse the following json into {"header_key1": "wife", "header_key2": "finish"} 🥲

⬇️ generated proto message from json {"header_key1": "wife", "header_key2": "finish"}

Message(
    DynamicMessage {
        desc: MessageDescriptor {
            name: "Struct",
            full_name: "google.protobuf.Struct",
            is_map_entry: false,
            fields: [
                FieldDescriptor {
                    name: "fields",
                    full_name: "google.protobuf.Struct.fields",
                    json_name: "fields",
                    number: 1,
                    kind: google.protobuf.Struct.FieldsEntry,
                    cardinality: Repeated,
                    containing_oneof: None,
                    default_value: None,
                    is_group: false,
                    is_list: false,
                    is_map: true,
                    is_packed: false,
                    supports_presence: false,
                },
            ],
            oneofs: [],
        },
        fields: DynamicMessageFieldSet {
            fields: {
                1: Value(
                    Map(
                        {
                            String(
                                "header_key1",
                            ): Message(
                                DynamicMessage {
                                    desc: MessageDescriptor {
                                        name: "Value",
                                        full_name: "google.protobuf.Value",
                                        is_map_entry: false,
                                        fields: [
                                            FieldDescriptor {
                                                name: "null_value",
                                                full_name: "google.protobuf.Value.null_value",
                                                json_name: "nullValue",
                                                number: 1,
                                                kind: google.protobuf.NullValue,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "number_value",
                                                full_name: "google.protobuf.Value.number_value",
                                                json_name: "numberValue",
                                                number: 2,
                                                kind: double,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "string_value",
                                                full_name: "google.protobuf.Value.string_value",
                                                json_name: "stringValue",
                                                number: 3,
                                                kind: string,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "bool_value",
                                                full_name: "google.protobuf.Value.bool_value",
                                                json_name: "boolValue",
                                                number: 4,
                                                kind: bool,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "struct_value",
                                                full_name: "google.protobuf.Value.struct_value",
                                                json_name: "structValue",
                                                number: 5,
                                                kind: google.protobuf.Struct,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "list_value",
                                                full_name: "google.protobuf.Value.list_value",
                                                json_name: "listValue",
                                                number: 6,
                                                kind: google.protobuf.ListValue,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                        ],
                                        oneofs: [
                                            OneofDescriptor {
                                                name: "kind",
                                                full_name: "google.protobuf.Value.kind",
                                                fields: [
                                                    FieldDescriptor {
                                                        name: "null_value",
                                                        full_name: "google.protobuf.Value.null_value",
                                                        json_name: "nullValue",
                                                        number: 1,
                                                        kind: google.protobuf.NullValue,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "number_value",
                                                        full_name: "google.protobuf.Value.number_value",
                                                        json_name: "numberValue",
                                                        number: 2,
                                                        kind: double,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "string_value",
                                                        full_name: "google.protobuf.Value.string_value",
                                                        json_name: "stringValue",
                                                        number: 3,
                                                        kind: string,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "bool_value",
                                                        full_name: "google.protobuf.Value.bool_value",
                                                        json_name: "boolValue",
                                                        number: 4,
                                                        kind: bool,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "struct_value",
                                                        full_name: "google.protobuf.Value.struct_value",
                                                        json_name: "structValue",
                                                        number: 5,
                                                        kind: google.protobuf.Struct,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "list_value",
                                                        full_name: "google.protobuf.Value.list_value",
                                                        json_name: "listValue",
                                                        number: 6,
                                                        kind: google.protobuf.ListValue,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                ],
                                            },
                                        ],
                                    },
                                    fields: DynamicMessageFieldSet {
                                        fields: {
                                            3: Value(
                                                String(
                                                    "wife",
                                                ),
                                            ),
                                        },
                                    },
                                },
                            ),
                            String(
                                "header_key2",
                            ): Message(
                                DynamicMessage {
                                    desc: MessageDescriptor {
                                        name: "Value",
                                        full_name: "google.protobuf.Value",
                                        is_map_entry: false,
                                        fields: [
                                            FieldDescriptor {
                                                name: "null_value",
                                                full_name: "google.protobuf.Value.null_value",
                                                json_name: "nullValue",
                                                number: 1,
                                                kind: google.protobuf.NullValue,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "number_value",
                                                full_name: "google.protobuf.Value.number_value",
                                                json_name: "numberValue",
                                                number: 2,
                                                kind: double,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "string_value",
                                                full_name: "google.protobuf.Value.string_value",
                                                json_name: "stringValue",
                                                number: 3,
                                                kind: string,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "bool_value",
                                                full_name: "google.protobuf.Value.bool_value",
                                                json_name: "boolValue",
                                                number: 4,
                                                kind: bool,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "struct_value",
                                                full_name: "google.protobuf.Value.struct_value",
                                                json_name: "structValue",
                                                number: 5,
                                                kind: google.protobuf.Struct,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                            FieldDescriptor {
                                                name: "list_value",
                                                full_name: "google.protobuf.Value.list_value",
                                                json_name: "listValue",
                                                number: 6,
                                                kind: google.protobuf.ListValue,
                                                cardinality: Optional,
                                                containing_oneof: Some(
                                                    "kind",
                                                ),
                                                default_value: None,
                                                is_group: false,
                                                is_list: false,
                                                is_map: false,
                                                is_packed: false,
                                                supports_presence: true,
                                            },
                                        ],
                                        oneofs: [
                                            OneofDescriptor {
                                                name: "kind",
                                                full_name: "google.protobuf.Value.kind",
                                                fields: [
                                                    FieldDescriptor {
                                                        name: "null_value",
                                                        full_name: "google.protobuf.Value.null_value",
                                                        json_name: "nullValue",
                                                        number: 1,
                                                        kind: google.protobuf.NullValue,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "number_value",
                                                        full_name: "google.protobuf.Value.number_value",
                                                        json_name: "numberValue",
                                                        number: 2,
                                                        kind: double,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "string_value",
                                                        full_name: "google.protobuf.Value.string_value",
                                                        json_name: "stringValue",
                                                        number: 3,
                                                        kind: string,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "bool_value",
                                                        full_name: "google.protobuf.Value.bool_value",
                                                        json_name: "boolValue",
                                                        number: 4,
                                                        kind: bool,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "struct_value",
                                                        full_name: "google.protobuf.Value.struct_value",
                                                        json_name: "structValue",
                                                        number: 5,
                                                        kind: google.protobuf.Struct,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                    FieldDescriptor {
                                                        name: "list_value",
                                                        full_name: "google.protobuf.Value.list_value",
                                                        json_name: "listValue",
                                                        number: 6,
                                                        kind: google.protobuf.ListValue,
                                                        cardinality: Optional,
                                                        containing_oneof: Some(
                                                            "kind",
                                                        ),
                                                        default_value: None,
                                                        is_group: false,
                                                        is_list: false,
                                                        is_map: false,
                                                        is_packed: false,
                                                        supports_presence: true,
                                                    },
                                                ],
                                            },
                                        ],
                                    },
                                    fields: DynamicMessageFieldSet {
                                        fields: {
                                            3: Value(
                                                String(
                                                    "finish",
                                                ),
                                            ),
                                        },
                                    },
                                },
                            ),
                        },
                    ),
                ),
            },
        },
    },
)

@tabVersion tabVersion added the help wanted Issues that need help from contributors label Jun 23, 2023
@neverchanje
Copy link
Contributor

@tabVersion Any context? I dont get the point. I thought that it would be straightforward to directly replace a struct with jsonb.

@tabVersion
Copy link
Contributor Author

@tabVersion Any context? I dont get the point. I thought that it would be straightforward to directly replace a struct with jsonb.

not really, protobuf wraps the json value in a really complex arch.
you may try to find header_key1 and wife in the generated message provided above and see how complex it is.

@github-actions
Copy link
Contributor

This PR has been open for 60 days with no activity. Could you please update the status? Feel free to ping a reviewer if you are waiting for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that need help from contributors no-pr-activity type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

frontend node stackoverflow while resolving recursive type of protobuf
4 participants