[
https://issues.apache.org/jira/browse/AVRO-1049?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrew Kenworthy updated AVRO-1049:
-----------------------------------
Description:
GenericData.Record#equals() does not return false when the schemas are not
equal: it currently only checks
the schema names as a performance optimization; this test code illustrates the
issue:
{quote}
@Test
public void test() {
Schema schema1 = Schema.createRecord("test_record", null, "my.namespace",
false);
List<Field> fields1 = new ArrayList<Field>();
fields1.add(new Field("attribute1", Schema.create(Schema.Type.STRING), null,
null, Order.IGNORE));
schema1.setFields(fields1);
Schema schema2 = Schema.createRecord("test_record", null, "my.namespace",
false);
List<Field> fields2 = new ArrayList<Field>();
fields2.add(new Field("attribute1", Schema.create(Schema.Type.STRING), null,
null, Order.ASCENDING));
schema2.setFields(fields2);
GenericRecord record1 = new GenericData.Record(schema1);
record1.put("attribute1", "1");
GenericRecord record2 = new GenericData.Record(schema2);
record2.put("attribute1", "2");
System.out.println(record1.equals(record2)); // returns TRUE
System.out.println(record2.equals(record1)); // returns FALSE
}
{quote}
See also:
http://mail-archives.apache.org/mod_mbox/avro-user/201202.mbox/%[email protected]%3E
was:
GenericData.Record#equals() does not return false when the schemas are not
equal: it currently only checks
the schema names as a performance optimization; this test code illustrates the
issue:
@Test
public void test() {
Schema schema1 = Schema.createRecord("test_record", null, "my.namespace",
false);
List<Field> fields1 = new ArrayList<Field>();
fields1.add(new Field("attribute1", Schema.create(Schema.Type.STRING), null,
null, Order.IGNORE));
schema1.setFields(fields1);
Schema schema2 = Schema.createRecord("test_record", null, "my.namespace",
false);
List<Field> fields2 = new ArrayList<Field>();
fields2.add(new Field("attribute1", Schema.create(Schema.Type.STRING), null,
null, Order.ASCENDING));
schema2.setFields(fields2);
GenericRecord record1 = new GenericData.Record(schema1);
record1.put("attribute1", "1");
GenericRecord record2 = new GenericData.Record(schema2);
record2.put("attribute1", "2");
System.out.println(record1.equals(record2)); // returns TRUE
System.out.println(record2.equals(record1)); // returns FALSE
}
See also:
http://mail-archives.apache.org/mod_mbox/avro-user/201202.mbox/%[email protected]%3E
> GenericData.Record#equals() does not return false when the schemas are not
> equal
> --------------------------------------------------------------------------------
>
> Key: AVRO-1049
> URL: https://issues.apache.org/jira/browse/AVRO-1049
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.6.0
> Reporter: Andrew Kenworthy
> Priority: Minor
>
> GenericData.Record#equals() does not return false when the schemas are not
> equal: it currently only checks
> the schema names as a performance optimization; this test code illustrates
> the issue:
> {quote}
> @Test
> public void test() {
> Schema schema1 = Schema.createRecord("test_record", null, "my.namespace",
> false);
> List<Field> fields1 = new ArrayList<Field>();
> fields1.add(new Field("attribute1", Schema.create(Schema.Type.STRING), null,
> null, Order.IGNORE));
> schema1.setFields(fields1);
> Schema schema2 = Schema.createRecord("test_record", null, "my.namespace",
> false);
> List<Field> fields2 = new ArrayList<Field>();
> fields2.add(new Field("attribute1", Schema.create(Schema.Type.STRING), null,
> null, Order.ASCENDING));
> schema2.setFields(fields2);
> GenericRecord record1 = new GenericData.Record(schema1);
> record1.put("attribute1", "1");
> GenericRecord record2 = new GenericData.Record(schema2);
> record2.put("attribute1", "2");
> System.out.println(record1.equals(record2)); // returns TRUE
> System.out.println(record2.equals(record1)); // returns FALSE
> }
> {quote}
> See also:
> http://mail-archives.apache.org/mod_mbox/avro-user/201202.mbox/%[email protected]%3E
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira