diff --git a/sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java b/sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java index 2b06f1e88d73..ec06865c5589 100644 --- a/sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java +++ b/sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java @@ -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; } @@ -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())); }