Skip to content

Commit

Permalink
Better error message when trying to get Beam Schema from proto schema…
Browse files Browse the repository at this point in the history
… with Struct (#32260)

* Better error message when trying to get Beam Schema from proto schema with Struct

* minor fix - consolidate
  • Loading branch information
Abacn authored Aug 21, 2024
1 parent ed4c03e commit a62ff34
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ static synchronized Schema getSchema(Descriptors.Descriptor descriptor) {
if (alreadyVisitedSchemas.containsKey(descriptor)) {
@Nullable Schema existingSchema = alreadyVisitedSchemas.get(descriptor);
if (existingSchema == null) {
String name = descriptor.getFullName();
if ("google.protobuf.Struct".equals(name)) {
throw new UnsupportedOperationException("Infer schema of Struct type is not supported.");
}
throw new IllegalArgumentException(
"Cannot infer schema with a circular reference. Proto Field: "
+ descriptor.getFullName());
"Cannot infer schema with a circular reference. Proto Field: " + name);
}
return existingSchema;
}
Expand Down Expand Up @@ -339,7 +342,7 @@ private static FieldType beamFieldTypeFromSingularProtoField(
fieldType = FieldType.logicalType(new NanosDuration());
break;
case "google.protobuf.Any":
throw new RuntimeException("Any not yet supported");
throw new UnsupportedOperationException("Any not yet supported");
default:
fieldType = FieldType.row(getSchema(protoFieldDescriptor.getMessageType()));
}
Expand Down

0 comments on commit a62ff34

Please sign in to comment.