mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-25 08:58:26 +00:00
fix(ingest): fix logic error of google protobuf wrapper type. (#7076)
Co-authored-by: david-leifker <114954101+david-leifker@users.noreply.github.com>
This commit is contained in:
parent
84f7f270ac
commit
65c275979b
@ -76,8 +76,8 @@ public class ProtobufField implements ProtobufElement {
|
||||
return nativeType();
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return fieldProto.getNumber();
|
||||
public int getNumber() {
|
||||
return fieldProto.getNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,7 +151,7 @@ public class ProtobufField implements ProtobufElement {
|
||||
|
||||
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() {
|
||||
@ -250,7 +250,11 @@ public class ProtobufField implements ProtobufElement {
|
||||
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) {
|
||||
|
||||
@ -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)
|
||||
@ -83,7 +83,7 @@ public class ProtobufFieldTest {
|
||||
@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")
|
||||
@ -121,7 +121,7 @@ public class ProtobufFieldTest {
|
||||
@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()
|
||||
@ -162,7 +162,7 @@ public class ProtobufFieldTest {
|
||||
@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")
|
||||
@ -206,7 +206,7 @@ public class ProtobufFieldTest {
|
||||
@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")
|
||||
@ -255,5 +255,14 @@ public class ProtobufFieldTest {
|
||||
.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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
syntax = "proto3";
|
||||
package extended_protobuf;
|
||||
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
|
||||
message UserMsg {
|
||||
message UserInfo {
|
||||
@ -8,7 +10,16 @@ message UserMsg {
|
||||
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.
Loading…
x
Reference in New Issue
Block a user