Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HUDI-8004] avoid unnecessary record rewrite during merging with base file #12683

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,18 @@ private static boolean isAtomicSchemasCompatible(Schema oneAtomicType, Schema an
* </ol>
*/
public static boolean isStrictProjectionOf(Schema sourceSchema, Schema targetSchema) {
return isProjectionOfInternal(sourceSchema, targetSchema, Objects::equals);
return isProjectionOfInternal(sourceSchema, targetSchema, AvroSchemaUtils::isAtomicTypeEquals);
}

private static boolean isAtomicTypeEquals(Schema source, Schema target) {
// ignore name/namespace for FIXED type
if (source.getType() == Schema.Type.FIXED && target.getType() == Schema.Type.FIXED) {
return source.getLogicalType().equals(target.getLogicalType())
&& source.getFixedSize() == target.getFixedSize()
&& source.getObjectProps().equals(target.getObjectProps());
} else {
return Objects.equals(source, target);
}
}

private static boolean isProjectionOfInternal(Schema sourceSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ public class TestAvroSchemaUtils {
+ " \"type\": [\"null\", \"int\"]\n"
+ " },\n"
+ " {\n"
+ " \"name\" : \"f1\",\n"
+ " \"type\" : [ \"null\", {\n"
+ " \"type\" : \"fixed\",\n"
+ " \"name\" : \"f1\",\n"
+ " \"namespace\" : \"\",\n"
+ " \"size\" : 5,\n"
+ " \"logicalType\" : \"decimal\",\n"
+ " \"precision\" : 10,\n"
+ " \"scale\" : 2\n"
+ " }],\n"
+ " \"default\" : null\n"
+ " },\n"
+ " {\n"
+ " \"name\": \"nested_record\",\n"
+ " \"type\": {\n"
+ " \"name\": \"nested\",\n"
Expand Down Expand Up @@ -76,6 +89,19 @@ public class TestAvroSchemaUtils {
+ " \"type\": [\"null\", \"int\"]\n"
+ " },\n"
+ " {\n"
+ " \"name\" : \"f1\",\n"
+ " \"type\" : [ \"null\", {\n"
+ " \"type\" : \"fixed\",\n"
+ " \"name\" : \"fixed\",\n"
+ " \"namespace\" : \"example.schema.source.f1\",\n"
+ " \"size\" : 5,\n"
+ " \"logicalType\" : \"decimal\",\n"
+ " \"precision\" : 10,\n"
+ " \"scale\" : 2\n"
+ " }],\n"
+ " \"default\" : null\n"
+ " },\n"
+ " {\n"
+ " \"name\": \"nested_record\",\n"
+ " \"type\": {\n"
+ " \"name\": \"nested\",\n"
Expand Down
Loading