[
https://issues.apache.org/jira/browse/AVRO-3612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17755681#comment-17755681
]
ASF subversion and git services commented on AVRO-3612:
-------------------------------------------------------
Commit 2722f9b533e9dbba0fe4c6461df418768f33496d in avro's branch
refs/heads/dependabot/cargo/lang/rust/master/color-backtrace-0.6.0 from
Christophe Le Saec
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=2722f9b53 ]
AVRO-3612: explain incompability for union (#2449)
> Report specific location of incompatibility in record schema
> ------------------------------------------------------------
>
> Key: AVRO-3612
> URL: https://issues.apache.org/jira/browse/AVRO-3612
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.11.1
> Reporter: Chin Huang
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.12.0
>
> Attachments: AVRO-3612.patch
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Given a reader schema for a record with a field having a mandatory value:
> {code:json}
> {
> "type" : "record",
> "name" : "Account",
> "fields" : [ {
> "name" : "age",
> "type" : "int"
> } ]
> }
> {code}
> and a writer schema for a record with a field having a nullable value:
> {code:json}
> {
> "type" : "record",
> "name" : "Account",
> "fields" : [ {
> "name" : "age",
> "type" : [ "null", "int" ],
> "default" : null
> } ]
> }
> {code}
> invoking SchemaCompatibility.checkReaderWriterCompatibility(readerSchema,
> writerSchema) finds an incompatibility with message:
> {noformat}
> reader type: INT not compatible with writer type: NULL{noformat}
> and location:
> {noformat}
> /{noformat}
> However, I want it to instead tell me the specific location of the
> incompatibility in the record schema:
> {noformat}
> /fields/0/type/0
> {noformat}
> This failing unit test demonstrates the bug:
> {code:java}
> class SchemaCompatibilityTest {
> @Test
> void
> given_incompatibility_in_record_schema_then_found_incompatibility_location() {
> var mandatorySchema = SchemaBuilder.record("Account").fields()
> .name("age").type().intType().noDefault()
> .endRecord();
> var optionalSchema = SchemaBuilder.record("Account").fields()
> .optionalInt("age")
> .endRecord();
> var compatibility = SchemaCompatibility.checkReaderWriterCompatibility(
> mandatorySchema, optionalSchema);
>
> assertThat(compatibility.getType()).isEqualTo(SchemaCompatibilityType.INCOMPATIBLE);
> var incompatibility =
> compatibility.getResult().getIncompatibilities().get(0);
> assertThat(incompatibility.getMessage()).isEqualTo("reader type: INT not
> compatible with writer type: NULL");
> assertThat(incompatibility.getLocation()).isEqualTo("/fields/0/type/0");
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)