Allow message_name field for protobuf ingestion (#9480)

This commit is contained in:
Ellie O'Neil 2023-12-19 09:24:03 -08:00 committed by GitHub
parent 265d6bdb53
commit 92c9940bbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 53 additions and 45 deletions

View File

@ -31,10 +31,10 @@ dependencies {
implementation externalDependency.commonsCli
implementation externalDependency.httpAsyncClient
implementation externalDependency.slf4jApi
implementation externalDependency.jacksonCore
compileOnly externalDependency.lombok
annotationProcessor externalDependency.lombok
testImplementation externalDependency.junitJupiterApi
testRuntimeOnly externalDependency.junitJupiterEngine
testImplementation externalDependency.testng
}
import java.nio.file.Paths
@ -61,10 +61,7 @@ jacocoTestReport {
dependsOn test // tests are required to run before generating the report
}
test {
useJUnit()
finalizedBy jacocoTestReport
}
test.finalizedBy jacocoTestReport
task checkShadowJar(type: Exec) {

View File

@ -67,6 +67,13 @@ public class Proto2DataHub {
"[Optional if using --directory] The protobuf source file. Typically a .proto file.")
.build();
private static final Option OPTION_MESSAGE_NAME =
Option.builder()
.longOpt("message_name")
.hasArg()
.desc("[Optional] The protobuf message name to read from.")
.build();
private static final Option OPTION_DIR =
Option.builder()
.longOpt("directory")
@ -166,6 +173,7 @@ public class Proto2DataHub {
private final String dataPlatform;
private final String protoc;
private final String inputFile;
private final String messageName;
private final String inputDir;
private final TransportOptions transport;
private final String filename;
@ -191,6 +199,7 @@ public class Proto2DataHub {
dataPlatform = cli.getOptionValue(OPTION_DATAHUB_PLATFORM, "kafka").toLowerCase(Locale.ROOT);
protoc = cli.getOptionValue(OPTION_DESCRIPTOR);
inputFile = cli.getOptionValue(OPTION_FILE, null);
messageName = cli.getOptionValue(OPTION_MESSAGE_NAME, null);
transport =
TransportOptions.valueOf(
cli.getOptionValue(OPTION_TRANSPORT, "rest").toUpperCase(Locale.ROOT));
@ -250,6 +259,7 @@ public class Proto2DataHub {
.addOption(OPTION_DATAHUB_TOKEN)
.addOption(OPTION_DESCRIPTOR)
.addOption(OPTION_FILE)
.addOption(OPTION_MESSAGE_NAME)
.addOption(OPTION_DIR)
.addOption(OPTION_EXCLUDE_PATTERN)
.addOption(OPTION_DATAHUB_USER)
@ -354,6 +364,7 @@ public class Proto2DataHub {
.setGithubOrganization(config.githubOrg)
.setSlackTeamId(config.slackId)
.setSubType(config.subType)
.setMessageName(config.messageName)
.build();
dataset

View File

@ -1,8 +1,8 @@
package datahub.protobuf;
import static datahub.protobuf.TestFixtures.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import com.linkedin.common.FabricType;
import com.linkedin.common.GlobalTags;
@ -34,7 +34,7 @@ import java.io.IOException;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class ProtobufDatasetTest {

View File

@ -2,13 +2,13 @@ package datahub.protobuf;
import static datahub.protobuf.TestFixtures.getTestProtobufFileSet;
import static datahub.protobuf.TestFixtures.getTestProtoc;
import static org.junit.jupiter.api.Assertions.*;
import static org.testng.Assert.*;
import com.google.protobuf.DescriptorProtos;
import com.google.protobuf.ExtensionRegistry;
import datahub.protobuf.model.ProtobufGraph;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class ProtobufUtilsTest {

View File

@ -1,6 +1,6 @@
package datahub.protobuf.model;
import static org.junit.jupiter.api.Assertions.*;
import static org.testng.Assert.*;
import com.google.protobuf.DescriptorProtos.DescriptorProto;
import com.google.protobuf.DescriptorProtos.EnumDescriptorProto;
@ -11,7 +11,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class ProtobufEnumTest {

View File

@ -1,7 +1,7 @@
package datahub.protobuf.model;
import static datahub.protobuf.TestFixtures.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.testng.Assert.*;
import com.google.protobuf.DescriptorProtos.DescriptorProto;
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto;
@ -22,7 +22,7 @@ import datahub.protobuf.ProtobufDataset;
import java.io.IOException;
import java.util.Arrays;
import java.util.Set;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class ProtobufFieldTest {
private static final DescriptorProto EXPECTED_MESSAGE_PROTO =

View File

@ -2,14 +2,14 @@ package datahub.protobuf.model;
import static datahub.protobuf.TestFixtures.getTestProtobufFileSet;
import static datahub.protobuf.TestFixtures.getTestProtobufGraph;
import static org.junit.jupiter.api.Assertions.*;
import static org.testng.Assert.*;
import com.google.protobuf.DescriptorProtos.FileDescriptorSet;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class ProtobufGraphTest {

View File

@ -1,6 +1,6 @@
package datahub.protobuf.model;
import static org.junit.jupiter.api.Assertions.*;
import static org.testng.Assert.*;
import com.google.protobuf.DescriptorProtos.DescriptorProto;
import com.google.protobuf.DescriptorProtos.FileDescriptorProto;
@ -11,7 +11,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class ProtobufMessageTest {

View File

@ -1,6 +1,6 @@
package datahub.protobuf.model;
import static org.junit.jupiter.api.Assertions.*;
import static org.testng.Assert.*;
import com.google.protobuf.DescriptorProtos.DescriptorProto;
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto;
@ -12,7 +12,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class ProtobufOneOfFieldTest {

View File

@ -2,7 +2,7 @@ package datahub.protobuf.visitors;
import static datahub.protobuf.TestFixtures.getTestProtobufFileSet;
import static datahub.protobuf.TestFixtures.getTestProtobufGraph;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.testng.Assert.assertNotEquals;
import com.google.protobuf.DescriptorProtos.FileDescriptorSet;
import datahub.protobuf.model.FieldTypeEdge;
@ -13,7 +13,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.jgrapht.GraphPath;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class VisitContextTest {

View File

@ -1,7 +1,7 @@
package datahub.protobuf.visitors.dataset;
import static datahub.protobuf.TestFixtures.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.common.urn.DatasetUrn;
import com.linkedin.data.template.RecordTemplate;
@ -14,7 +14,7 @@ import java.net.URISyntaxException;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class DatasetVisitorTest {

View File

@ -1,14 +1,14 @@
package datahub.protobuf.visitors.dataset;
import static datahub.protobuf.TestFixtures.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import datahub.protobuf.model.ProtobufGraph;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class DescriptionVisitorTest {

View File

@ -2,7 +2,7 @@ package datahub.protobuf.visitors.dataset;
import static datahub.protobuf.TestFixtures.getTestProtobufGraph;
import static datahub.protobuf.TestFixtures.getVisitContextBuilder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.common.urn.Urn;
import datahub.protobuf.model.ProtobufGraph;
@ -10,7 +10,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class DomainVisitorTest {

View File

@ -1,7 +1,7 @@
package datahub.protobuf.visitors.dataset;
import static datahub.protobuf.TestFixtures.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.common.InstitutionalMemoryMetadata;
import com.linkedin.common.url.Url;
@ -9,7 +9,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class InstitutionalMemoryVisitorTest {

View File

@ -2,7 +2,7 @@ package datahub.protobuf.visitors.dataset;
import static datahub.protobuf.TestFixtures.getTestProtobufGraph;
import static datahub.protobuf.TestFixtures.getVisitContextBuilder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.data.template.StringMap;
import com.linkedin.dataset.DatasetProperties;
@ -11,7 +11,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class KafkaTopicPropertyVisitorTest {

View File

@ -2,7 +2,7 @@ package datahub.protobuf.visitors.dataset;
import static datahub.protobuf.TestFixtures.getTestProtobufGraph;
import static datahub.protobuf.TestFixtures.getVisitContextBuilder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.common.Owner;
import com.linkedin.common.OwnershipSource;
@ -14,7 +14,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class OwnershipVisitorTest {

View File

@ -3,7 +3,7 @@ package datahub.protobuf.visitors.dataset;
import static datahub.protobuf.TestFixtures.getTestProtobufGraph;
import static datahub.protobuf.TestFixtures.getVisitContextBuilder;
import static java.util.Map.entry;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.data.template.StringMap;
import com.linkedin.dataset.DatasetProperties;
@ -11,7 +11,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class PropertyVisitorTest {

View File

@ -2,7 +2,7 @@ package datahub.protobuf.visitors.dataset;
import static datahub.protobuf.TestFixtures.getTestProtobufGraph;
import static datahub.protobuf.TestFixtures.getVisitContextBuilder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.common.GlossaryTermAssociation;
import com.linkedin.common.urn.GlossaryTermUrn;
@ -10,7 +10,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class TermAssociationVisitorTest {

View File

@ -1,7 +1,7 @@
package datahub.protobuf.visitors.field;
import static datahub.protobuf.TestFixtures.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.common.GlobalTags;
import com.linkedin.common.GlossaryTermAssociation;
@ -23,7 +23,7 @@ import java.net.URISyntaxException;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class ProtobufExtensionFieldVisitorTest {

View File

@ -2,7 +2,7 @@ package datahub.protobuf.visitors.field;
import static datahub.protobuf.TestFixtures.getTestProtobufGraph;
import static datahub.protobuf.TestFixtures.getVisitContextBuilder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.schema.NumberType;
import com.linkedin.schema.SchemaField;
@ -15,7 +15,7 @@ import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class SchemaFieldVisitorTest {

View File

@ -2,7 +2,7 @@ package datahub.protobuf.visitors.tag;
import static datahub.protobuf.TestFixtures.getTestProtobufGraph;
import static datahub.protobuf.TestFixtures.getVisitContextBuilder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.testng.Assert.assertEquals;
import com.linkedin.tag.TagProperties;
import datahub.event.MetadataChangeProposalWrapper;
@ -11,7 +11,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.testng.annotations.Test;
public class TagVisitorTest {