Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datahub project Datahub TagVisitor

From Leeroopedia


Knowledge Sources
Domains Protobuf_Integration, Tag_Management
Last Updated 2026-02-10 00:00 GMT

Overview

Description

TagVisitor is a visitor that creates DataHub tag entities from protobuf extension options. It implements ProtobufModelVisitor<MetadataChangeProposalWrapper<? extends RecordTemplate>> and processes both message-level and field-level options to produce tagProperties aspect MCPs.

The visitor extracts tag properties from protobuf options using ProtobufExtensionUtil.extractTagPropertiesFromOptions and wraps each extracted TagProperties into a MetadataChangeProposalWrapper targeting the "tag" entity type with a TagUrn derived from the tag name.

This visitor creates the tag entities themselves (via tagProperties aspect), as distinct from the tag associations on datasets and fields handled by other visitors.

Usage

Typically used alongside DatasetVisitor to ensure that any tags referenced from protobuf extensions are created as first-class tag entities in DataHub.

Code Reference

Source Location

metadata-integration/java/datahub-protobuf/src/main/java/datahub/protobuf/visitors/tags/TagVisitor.java

Signature

public class TagVisitor
    implements ProtobufModelVisitor<MetadataChangeProposalWrapper<? extends RecordTemplate>> {

    @Override
    public Stream<MetadataChangeProposalWrapper<? extends RecordTemplate>> visitGraph(
        VisitContext context)

    @Override
    public Stream<MetadataChangeProposalWrapper<? extends RecordTemplate>> visitField(
        ProtobufField field, VisitContext context)
}

Import

import datahub.protobuf.visitors.tags.TagVisitor;

I/O Contract

Inputs

Method Parameter Type Description
visitGraph context VisitContext Visit context providing root message, graph, and registry
visitField field ProtobufField The field whose options to extract tags from
visitField context VisitContext Visit context providing graph and registry

Outputs

Method Return Type Description
visitGraph Stream<MetadataChangeProposalWrapper<? extends RecordTemplate>> MCPs creating tag entities from message-level options
visitField Stream<MetadataChangeProposalWrapper<? extends RecordTemplate>> MCPs creating tag entities from field-level options

Each MCP has:

  • Entity type: "tag"
  • Entity URN: TagUrn derived from tagProperties.getName()
  • Change type: UPSERT
  • Aspect name: "tagProperties"

Usage Examples

TagVisitor tagVisitor = new TagVisitor();

// Visit message-level tags
Stream<MetadataChangeProposalWrapper<? extends RecordTemplate>> tagMcps =
    tagVisitor.visitGraph(visitContext);

// Visit field-level tags
Stream<MetadataChangeProposalWrapper<? extends RecordTemplate>> fieldTagMcps =
    tagVisitor.visitField(protobufField, visitContext);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment