datahub.protobuf.visitors.field.SchemaFieldVisitor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datahub-protobuf Show documentation
Show all versions of datahub-protobuf Show documentation
DataHub integration with Protobuf schemas for metadata
package datahub.protobuf.visitors.field;
import com.linkedin.schema.SchemaField;
import com.linkedin.util.Pair;
import datahub.protobuf.model.ProtobufField;
import datahub.protobuf.visitors.ProtobufModelVisitor;
import datahub.protobuf.visitors.VisitContext;
import java.util.stream.Stream;
public class SchemaFieldVisitor implements ProtobufModelVisitor> {
@Override
public Stream> visitField(ProtobufField field, VisitContext context) {
return context
.streamAllPaths(field)
.map(
path ->
Pair.of(
new SchemaField()
.setFieldPath(context.getFieldPath(path))
.setNullable(true)
.setDescription(field.comment())
.setNativeDataType(field.nativeType())
.setType(field.schemaFieldDataType()),
context.calculateSortOrder(path, field)));
}
}