[ 
https://issues.apache.org/jira/browse/AVRO-3814?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17754862#comment-17754862
 ] 

ASF subversion and git services commented on AVRO-3814:
-------------------------------------------------------

Commit 598911d80ea2feda984624632679b0e6e2696b9b in avro's branch 
refs/heads/dependabot/cargo/lang/rust/master/color-backtrace-0.6.0 from Martin 
Grigorov
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=598911d80 ]

AVRO-3814: Fix schema resolution for records in union types (#2441)

* AVRO-3814: Add a minimal test-case to reproduce

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* AVRO-3814: Fix schema resolution for records in union types

The logic for validation records in Value::validate_internal() would be
too strict when resolving union types containing a record. This could
lead to a situation where schema resolution would fail because the
correct schema to use for a union type could not be identified.

This commit fixes this by passing a boolean `schema_resolution` to
`Value::validate_internal()` which governs whether schema_resolution
rules should be applied.

* AVRO-3814: Ensure to validate the deserialized value against the schema

* AVRO-3814: Extend test case for validate_record

* AVRO-3814: Revert whitespace changes

* AVRO-3814: Remove confusing comments

* AVRO-3786: Add test-cases and fix for AVRO-3786

* AVRO-3786: Revert change to UnionSchema::find_schema_with_known_schemata

* AVRO-3814: [Rust] Use types::Value::resolve_internal() instead of 
validate_internal()

... when looking for the matching schema in an union

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* AVRO-3814: Revert changes to validate_internal()

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* AVRO-3814: Remove obsolete rustdoc for arguments

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

---------

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Co-authored-by: Rik Heijdens <[email protected]>

> [Rust] Schema resolution fails when extending a nested record with a union 
> type
> -------------------------------------------------------------------------------
>
>                 Key: AVRO-3814
>                 URL: https://issues.apache.org/jira/browse/AVRO-3814
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: rust
>            Reporter: Rik Heijdens
>            Assignee: Martin Tzvetanov Grigorov
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.12.0, 1.11.3
>
>          Time Spent: 3h 20m
>  Remaining Estimate: 0h
>
> Consider the following schema:
> {noformat}
> {
>     "type": "record",
>     "name": "MyOuterRecord",
>     "fields": [
>         {
>             "name": "inner_record",
>             "type": [
>                 "null",
>                 {
>                     "type": "record",
>                     "name": "MyRecord",
>                     "fields": [
>                         {"name": "a", "type": "string"}
>                     ]
>                 }
>             ],
>             "default": null
>         }
>     ]
> }
> {noformat}
> Over time one might decide to add a new optional enum field 'b' to 
> `MyRecord`, resulting in the following schema:
> {noformat}
> {
>     "type": "record",
>     "name": "MyOuterRecord",
>     "fields": [
>         {
>             "name": "inner_record",
>             "type": [
>                 "null",
>                 {
>                     "type": "record",
>                     "name": "MyRecord",
>                     "fields": [
>                         {"name": "a", "type": "string"},
>                         {
>                             "name": "b",
>                             "type": [
>                                 "null",
>                                 {
>                                     "type": "enum",
>                                     "name": "MyEnum",
>                                     "symbols": ["A", "B", "C"],
>                                     "default": "C"
>                                 }
>                             ],
>                             "default": null
>                         }
>                     ]
>                 }
>             ]
>         }
>     ],
>     "default": null
> }
> {noformat}
> When one then serializes a message with the updated schema, and then attempts 
> to deserialize it using the updated schema, while attempting to resolve it 
> with the earlier schema, then schema resolution in Value::resolve_union() 
> fails with `Error::FindUnionVariant`. This appears to be caused by 
> `UnionSchema.find_schema_with_known_schemata()` failing to resolve the schema 
> appropriately.
> I would not expect schema resolution to fail in this case. I will accompany 
> this ticket with a test-case that allows reproduction.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to