[
https://issues.apache.org/jira/browse/AVRO-3778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17733380#comment-17733380
]
Oscar Westra van Holthe - Kind commented on AVRO-3778:
------------------------------------------------------
Another question: would it make sense to make this equivalence wider? That is,
treat any two schemas as equivalent if data written with one can be read with
the other, and vice versa? That is, also ignore fields that occur only in one
of the two, if the fields have default values?
(note that the way Avro works, this requires both schemata in either case)
This can already be checked (at least in Java) like this:
{code:java}
// import static
org.apache.avro.SchemaCompatibility.checkReaderWriterCompatibility;
boolean equivalent =
checkReaderWriterCompatibility(schema1, schema2) && // data written with
schema2 can be read as schema1,
checkReaderWriterCompatibility(schema2, schema1); // and data written with
schema1 can be read as schema2
{code}
> Ability to perform semantic equality check for two schemas
> ----------------------------------------------------------
>
> Key: AVRO-3778
> URL: https://issues.apache.org/jira/browse/AVRO-3778
> Project: Apache Avro
> Issue Type: Improvement
> Components: java
> Reporter: Swaranga Sarma
> Priority: Major
>
> I would like to check if two schemas are equivalent. For instance:
> {{{"type":"record","name":"Person","fields":[\{"name":"name","type":"string"},\{"name":"age","type":"int"}]}}}
> {{and}}
> {{{"type":"record","name":"Person","fields":[\{"name":"age","type":"int"},\{"name":"name","type":"string"}]}}}
> can be considered semantically equivalent since the record has the same set
> of fields only just reordered in the declaration.
> If I do {{schema1.equals(schema2)}} for the above, the Avro Java library will
> say false. Would it be reasonable to add an "equivalence" method to detect
> such cases?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)