Skip to content

Commit

Permalink
Revert "fix: properly validate that aspects can only be of type record (
Browse files Browse the repository at this point in the history
#144)" (#149)

This reverts commit d2d88bb.
  • Loading branch information
zhixuanjia authored Mar 3, 2022
1 parent 881a45e commit 1f7ce0a
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace com.linkedin.metadata.dummy

import com.linkedin.common.Urn

/**
* Not to be used
*/
typeref DummyAspect = union[DummyRecord]
typeref DummyAspect = union[Urn]

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion validators/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ dependencies {
annotationProcessor externalDependency.lombok

testCompile externalDependency.guava
testCompile project(':testing:test-models')
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private AspectValidator() {
*/
public static void validateAspectUnionSchema(@Nonnull UnionDataSchema schema, @Nonnull String aspectClassName) {

if (!ValidationUtils.isUnionWithOnlyRecordMembers(schema)) {
if (!ValidationUtils.isUnionWithOnlyComplexMembers(schema)) {
ValidationUtils.invalidSchema("Aspect '%s' must be a union containing only record type members", aspectClassName);
}
}
Expand All @@ -47,7 +47,7 @@ public static void validateAspectUnionSchema(@Nonnull Class<? extends UnionTempl

private static boolean isValidMetadataField(RecordDataSchema.Field field) {
return field.getName().equals("metadata") && !field.getOptional()
&& field.getType().getType() == DataSchema.Type.UNION && ValidationUtils.isUnionWithOnlyRecordMembers(
&& field.getType().getType() == DataSchema.Type.UNION && ValidationUtils.isUnionWithOnlyComplexMembers(
(UnionDataSchema) field.getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void validateEntityUnionSchema(@Nonnull Class<? extends UnionTempl
*/
public static void validateEntityUnionSchema(@Nonnull UnionDataSchema schema, @Nonnull String entityClassName) {

if (!ValidationUtils.isUnionWithOnlyRecordMembers(schema)) {
if (!ValidationUtils.isUnionWithOnlyComplexMembers(schema)) {
ValidationUtils.invalidSchema("Entity '%s' must be a union containing only record type members", entityClassName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void validateRelationshipUnionSchema(@Nonnull Class<? extends Unio
*/
public static void validateRelationshipUnionSchema(@Nonnull UnionDataSchema schema, @Nonnull String relationshipClassName) {

if (!ValidationUtils.isUnionWithOnlyRecordMembers(schema)) {
if (!ValidationUtils.isUnionWithOnlyComplexMembers(schema)) {
ValidationUtils.invalidSchema("Relationship '%s' must be a union containing only record type members", relationshipClassName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ public static List<RecordDataSchema.Field> fieldsUsingInvalidType(@Nonnull Recor
.collect(Collectors.toList());
}

public static boolean isUnionWithOnlyRecordMembers(UnionDataSchema unionDataSchema) {
return unionDataSchema.getMembers().stream().allMatch(member -> member.getType().getDereferencedDataSchema().getType().equals(
DataSchema.Type.RECORD));
public static boolean isUnionWithOnlyComplexMembers(UnionDataSchema unionDataSchema) {
return unionDataSchema.getMembers().stream().allMatch(member -> member.getType().isComplex());
}

@Nonnull
Expand Down

This file was deleted.

0 comments on commit 1f7ce0a

Please sign in to comment.