-
Notifications
You must be signed in to change notification settings - Fork 1k
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
ksqlDB engine does not infer the Struct type correctly from protobuf schema #7642
Comments
Also tested and reproduced the issue with a trimmed-down schema:
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"schemaType":"PROTOBUF","schema":"syntax = \"proto3\";\npackage google.protobuf;\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption cc_enable_arenas = true;\noption go_package = \"google.golang.org/protobuf/types/known/wrapperspb\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"WrappersProto\";\noption java_multiple_files = true;\noption objc_class_prefix = \"GPB\";\n\nmessage DoubleValue {\n // The double value.\n double value = 1;\n}\nmessage FloatValue {\n // The float value.\n float value = 1;\n}\nmessage Int64Value {\n // The int64 value.\n int64 value = 1;\n}\nmessage UInt64Value {\n // The uint64 value.\n uint64 value = 1;\n}\nmessage Int32Value {\n // The int32 value.\n int32 value = 1;\n}\nmessage UInt32Value {\n // The uint32 value.\n uint32 value = 1;\n}\nmessage BoolValue {\n // The bool value.\n bool value = 1;\n}\nmessage StringValue {\n // The string value.\n string value = 1;\n}\nmessage BytesValue {\n // The bytes value.\n bytes value = 1;\n}\n"}' \
http://localhost:8081/subjects/google%2Fprotobuf%2Fwrappers.proto/versions
{"id":1}
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{
"schemaType": "PROTOBUF",
"references": [
{
"name": "google/protobuf/wrappers.proto",
"subject": "google/protobuf/wrappers.proto",
"version": 1
}
],
"schema": "syntax = \"proto3\";\n\npackage com.acme;\noption java_package = \"com.acme\";\n\nimport \"google/protobuf/wrappers.proto\";\n\nmessage MyMessage {\nstring value = 1;\ngoogle.protobuf.StringValue wrappedValue = 2;\n}\n"
}' \
http://localhost:8081/subjects/test-value/versions
{"id":2}
kafka-protobuf-console-producer --bootstrap-server localhost:9092 --property value.schema.id=2 --topic test <<EOF
{"value":"hi","wrappedValue":"there"}
EOF Use of wrapper types is working fine with ksqlDB 6.1.1 and through 0.15.0 with SR 6.1.1, inferring
In ksqlDB 0.17.0 and 0.18.0, ksqlDB creates the wrapped field as a primitive type, which results in the error at processing time:
|
Seems a bug with the Protobuf converter. The bug is reported here - https://confluentinc.atlassian.net/browse/DGS-1726 |
Just noticed the link posted above is not public. For more info, the issue is caused by a SchemaRegistry bug which caused protobuf converter not converting wrappers to structs. This is a regression issue in SchemaRegistry. Update: The issue in SR is fixed now. The fix in ksqlDB should be available in master as soon as CP artifacts with the SR bugfix are ready. |
The fix for this issue will be included in the next ksqlDB standalone and cloud release: 0.19.0. |
@colinhicks I see that 0.19 is out but don't see the fix in the changelog notes also this PR is still open. did it not make 0.19? Or is it planned for a fix version of 0.19? |
Hi @cdadia, thanks for pinging about this. Since the team addressed the issue in an upstream dependency and not directly in the ksql codebase, the workflow was a bit different in this case. My intention was to close this at the time of the official release announcement for 0.19 – slated for today. We will also add it to the changelog, which as of now comprises changes from PRs into this repository. |
@colinhicks Thanks. I have validated that the use case outlined in the description of this ticket is fixed with 0.19 release. |
Great. Thanks for verifying! |
Describe the bug
ksqlDB infers incorrect Struct type for fields in the stream collection for topic with a registered protobuf schema. In the described example, the correct type should have been
StringValue
but it is inferred asVARCHAR(STRING)
In this example, it happens to be a type defined in the reference from
google/protobuf/wrappers.proto
but I suspect this is true for anyStruct
type defined in a reference.To Reproduce
Steps to reproduce the behavior, include:
Executed the statements in the following order
Create a topic
Register the schema with schema registry for reference
paymentEnums.proto
Register the schema with schema registry for
test_topic-value
Check schema was registered correctly:
Start a ksqlDB cli client and execute the following steps:
Set offset to earliest
Create the stream
List all the streams
Describe the stream
Open separate ksqldb-cli client sessions and watch for processing results
client session 1:
client session 2:
client session 3:
Expected behavior
reason_code
,charge_id
,refund_id
,transaction_id
andorder_item_id
should beStringValue
but it is inferred asVARCHAR(STRING)
Actual behaviour
client session 1:
client session 2:
client session 3:
Additional context
Google wrapper proto file:
https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/wrappers.proto
Also, used this documentation as a reference to check if nested fields are supported in ksqlDB
https://docs.ksqldb.io/en/0.8.x-ksqldb/operate-and-deploy/installation/server-config/avro-schema/#supported-functionality
The text was updated successfully, but these errors were encountered: