Skip to content

Commit

Permalink
Merge branch '7.5.x' into 7.6.x by rayokota
Browse files Browse the repository at this point in the history
  • Loading branch information
semaphore-agent-production[bot] committed Jan 18, 2025
2 parents 7be77ea + 6c46a9b commit b8346f9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,41 @@ public void testEnumWithDefault() {
assertNotEquals(new AvroSchema(enumSchema), new AvroSchema(enumSchemaWithDefault));
}

@Test
public void testArrayWithDoc() {
String s1 = "\n"
+ "{\n"
+ " \"type\": \"array\",\n"
+ " \"items\": { \n"
+ " \"type\": \"record\",\n"
+ " \"name\": \"top\",\n"
+ " \"doc\": \"test\",\n"
+ " \"fields\": [\n"
+ " {\n"
+ " \"name\": \"field1\",\n"
+ " \"type\": \"string\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";
String s2 = "\n"
+ "{\n"
+ " \"type\": \"array\",\n"
+ " \"items\": { \n"
+ " \"type\": \"record\",\n"
+ " \"name\": \"top\",\n"
+ " \"doc\": \"test2\",\n"
+ " \"fields\": [\n"
+ " {\n"
+ " \"name\": \"field1\",\n"
+ " \"type\": \"string\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";
assertNotEquals(new AvroSchema(s1), new AvroSchema(s2));
}

@Test
public void testBasicAddAndRemoveTags() {
String schemaString = "{\n" +
Expand Down Expand Up @@ -1297,7 +1332,6 @@ public void testTagsInsertionOrder() {

ParsedSchema resultSchema = schema.copy(tags, Collections.emptyMap());
assertEquals(expectSchema.canonicalString(), resultSchema.canonicalString());

}

private static void expectConversionException(JsonNode obj, AvroSchema schema) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ private boolean metaEqual(
return Objects.equals(schema1.getAliases(), schema2.getAliases())
&& Objects.equals(schema1.getDoc(), schema2.getDoc())
&& Objects.equals(schema1.getEnumDefault(), schema2.getEnumDefault());
case ARRAY:
return metaEqual(schema1.getElementType(), schema2.getElementType(), cache);
case MAP:
return metaEqual(schema1.getValueType(), schema2.getValueType(), cache);
case FIXED:
return Objects.equals(schema1.getAliases(), schema2.getAliases())
&& Objects.equals(schema1.getDoc(), schema2.getDoc());
Expand Down Expand Up @@ -501,6 +505,10 @@ private int metaHash(Schema schema, Map<Schema, Integer> cache) {
return result;
case ENUM:
return Objects.hash(schema.getAliases(), schema.getDoc(), schema.getEnumDefault());
case ARRAY:
return metaHash(schema.getElementType(), cache);
case MAP:
return metaHash(schema.getValueType(), cache);
case FIXED:
return Objects.hash(schema.getAliases(), schema.getDoc());
case UNION:
Expand Down

0 comments on commit b8346f9

Please sign in to comment.