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

fix(ingest): fix logic error of google protobuf wrapper type. #7076

Merged
Merged
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 @@ -76,8 +76,8 @@ public String getNativeType() {
return nativeType();
}

public int getNumber() {
return fieldProto.getNumber();
public int getNumber() {
return fieldProto.getNumber();
}

@Override
Expand Down Expand Up @@ -151,7 +151,7 @@ public String fieldPathType() {

public boolean isMessage() {
return Optional.ofNullable(isMessageType).orElseGet(() ->
fieldProto.getType().equals(FieldDescriptorProto.Type.TYPE_MESSAGE));
fieldProto.getType().equals(FieldDescriptorProto.Type.TYPE_MESSAGE));
}

public int sortWeight() {
Expand Down Expand Up @@ -250,7 +250,11 @@ private FieldDescriptorProto getNestedTypeFields(List<Integer> pathList, Descrip
messageType = messageType.getNestedType(value);
}

return messageType.getField(pathList.get(pathList.size() - 1));
if (pathList.get(pathSize - 2) == DescriptorProto.FIELD_FIELD_NUMBER) {
return messageType.getField(pathList.get(pathSize - 1));
} else {
return null;
}
}

private boolean isEnumType(List<Integer> pathList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ProtobufFieldTest {

@Test
public void fieldTest() {
FieldDescriptorProto expectedField = FieldDescriptorProto.newBuilder()
FieldDescriptorProto expectedField = FieldDescriptorProto.newBuilder()
.setName("field1")
.setNumber(1)
.setType(FieldDescriptorProto.Type.TYPE_BYTES)
Expand Down Expand Up @@ -83,7 +83,7 @@ public void fieldTest() {
@Test
public void fieldPathTypeTest() {
Arrays.stream(FieldDescriptorProto.Type.values()).forEach(type -> {
final FieldDescriptorProto expectedField;
final FieldDescriptorProto expectedField;
if (type == FieldDescriptorProto.Type.TYPE_MESSAGE) {
expectedField = FieldDescriptorProto.newBuilder()
.setName("field1")
Expand Down Expand Up @@ -121,7 +121,7 @@ public void fieldPathTypeTest() {
@Test
public void fieldPathTypeArrayTest() {
Arrays.stream(FieldDescriptorProto.Type.values()).forEach(type -> {
final FieldDescriptorProto expectedField;
final FieldDescriptorProto expectedField;

if (type == FieldDescriptorProto.Type.TYPE_MESSAGE) {
expectedField = FieldDescriptorProto.newBuilder()
Expand Down Expand Up @@ -162,7 +162,7 @@ public void fieldPathTypeArrayTest() {
@Test
public void schemaFieldTypeTest() {
Arrays.stream(FieldDescriptorProto.Type.values()).forEach(type -> {
final FieldDescriptorProto expectedField;
final FieldDescriptorProto expectedField;
if (type == FieldDescriptorProto.Type.TYPE_MESSAGE) {
expectedField = FieldDescriptorProto.newBuilder()
.setName("field1")
Expand Down Expand Up @@ -206,7 +206,7 @@ public void schemaFieldTypeTest() {
@Test
public void schemaFieldTypeArrayTest() {
Arrays.stream(FieldDescriptorProto.Type.values()).forEach(type -> {
final FieldDescriptorProto expectedField;
final FieldDescriptorProto expectedField;
if (type == FieldDescriptorProto.Type.TYPE_MESSAGE) {
expectedField = FieldDescriptorProto.newBuilder()
.setName("field1")
Expand Down Expand Up @@ -255,5 +255,14 @@ public void nestedTypeFieldTest() throws IOException {
.orElseThrow();

assertEquals("profile url info", profileUrlField.getDescription());

SchemaField addressField = testMetadata.getFields()
.stream().filter(f -> f.getFieldPath()
.equals("[version=2.0].[type=extended_protobuf_UserMsg]."
+ "[type=extended_protobuf_UserMsg_AddressMsg].address.[type=google_protobuf_StringValue].zipcode"))
.findFirst()
.orElseThrow();

assertEquals("Zip code, alphanumeric", addressField.getDescription());
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
syntax = "proto3";
package extended_protobuf;

import "google/protobuf/wrappers.proto";


message UserMsg {
message UserInfo {
string nickname = 1; // nickname info
string profile_url = 2; // profile url info
}

message AddressMsg {
google.protobuf.StringValue zipcode = 1; // Zip code, alphanumeric
google.protobuf.StringValue city = 2; // City corresponding to zip code
google.protobuf.StringValue country = 3; // County
}

string id = 1; // user id
string name = 2; // user name
UserInfo user_info = 3; // user info

// address
AddressMsg address = 4;
}
Binary file not shown.