📊 Data Engineering

Data Catalog

Data Catalog

Inventory and search of data assets. Metadata management.

Detailed Explanation

A data catalog is a system that inventories all data assets in an organization and manages metadata. It serves as a central hub for data discovery, understanding, and trust, and is core infrastructure for data governance and self-service analytics. It provides answers to "what data exists, where it is, what it means, and who owns it."

A data catalog manages three types of metadata. First, technical metadata, which includes schemas, data types, storage locations, and partition information. Second, business metadata, which includes dataset descriptions, tags, classifications, owners, and links to the business glossary. Third, operational metadata, which tracks access logs, usage frequency, freshness, and quality scores.

Its main features include automatic metadata crawling (automatically collecting schemas from databases, data lakes, and BI tools), search and discovery (finding datasets by keyword, tag, and domain), data lineage integration (tracking data flows and impact analysis), collaboration features (documentation, ratings, Q&A, owner assignment), and access control (per-dataset permission management and request workflows).

Representative data catalog solutions include the open-source DataHub (LinkedIn), Amundsen (Lyft), and Apache Atlas, and the commercial solutions Alation, Collibra, and Informatica. Cloud-based options include AWS Glue Data Catalog, Google Data Catalog, and Azure Purview. In data lakehouses, Unity Catalog (Databricks) provides unified governance.

Code Example

DataHub Python SDK
# DataHub을 활용한 데이터 카탈로그 메타데이터 등록
from datahub.emitter.mce_builder import (
    make_dataset_urn, make_tag_urn, make_term_urn,
    make_user_urn, make_domain_urn
)
from datahub.emitter.rest_emitter import DatahubRestEmitter
from datahub.metadata.schema_classes import (
    DatasetPropertiesClass, SchemaMetadataClass,
    SchemaFieldClass, StringTypeClass, NumberTypeClass,
    OwnershipClass, OwnerClass, OwnershipTypeClass,
    GlobalTagsClass, TagAssociationClass,
    GlossaryTermsClass, GlossaryTermAssociationClass,
    DomainsClass, StatusClass
)
from datahub.emitter.mcp import MetadataChangeProposalWrapper

# DataHub GMS 서버 연결
emitter = DatahubRestEmitter(
    gms_server="http://datahub-gms:8080",
    token="your-access-token"
)

# 1. 데이터셋 URN 생성 (고유 식별자)
dataset_urn = make_dataset_urn(
    platform="snowflake",
    name="analytics.gold.customer_360",
    env="PROD"
)

# 2. 데이터셋 속성 정의 (비즈니스 메타데이터)
properties = DatasetPropertiesClass(
    name="customer_360",
    description="""
    통합 고객 360도 뷰 테이블.
    주문, 행동, CRM 데이터를 결합한 분석용 마트.

    사용 사례:
    - 고객 세그먼테이션
    - LTV 예측 모델 학습
    - 마케팅 캠페인 타겟팅
    """,
    qualifiedName="analytics.gold.customer_360",
    customProperties={
        "refresh_frequency": "hourly",
        "data_owner": "analytics-team",
        "pii_classification": "confidential",
        "row_count": "15,000,000",
        "data_quality_score": "95%"
    }
)

# 3. 스키마 정의 (기술적 메타데이터)
schema = SchemaMetadataClass(
    schemaName="customer_360",
    platform=make_dataset_urn("snowflake", "", "PROD"),
    version=0,
    hash="",
    platformSchema={},
    fields=[
        SchemaFieldClass(
            fieldPath="customer_id",
            type=StringTypeClass(),
            nativeDataType="VARCHAR(50)",
            description="고객 고유 식별자 (UUID)",
            nullable=False,
            isPartOfKey=True
        ),
        SchemaFieldClass(
            fieldPath="email",
            type=StringTypeClass(),
            nativeDataType="VARCHAR(255)",
            description="고객 이메일 주소 (개인정보)",
            nullable=True,
            globalTags=GlobalTagsClass(tags=[
                TagAssociationClass(tag=make_tag_urn("PII")),
                TagAssociationClass(tag=make_tag_urn("Sensitive"))
            ])
        ),
        SchemaFieldClass(
            fieldPath="lifetime_value",
            type=NumberTypeClass(),
            nativeDataType="DECIMAL(18,2)",
            description="고객 생애 가치 (LTV, USD)",
            nullable=True
        ),
        SchemaFieldClass(
            fieldPath="segment",
            type=StringTypeClass(),
            nativeDataType="VARCHAR(20)",
            description="고객 세그먼트 (VIP/Standard/Basic)",
            nullable=False
        ),
        SchemaFieldClass(
            fieldPath="last_activity_date",
            type=StringTypeClass(),
            nativeDataType="DATE",
            description="마지막 활동 일자",
            nullable=True
        )
    ]
)

# 4. 소유권 설정
ownership = OwnershipClass(
    owners=[
        OwnerClass(
            owner=make_user_urn("analytics_lead"),
            type=OwnershipTypeClass.DATAOWNER
        ),
        OwnerClass(
            owner=make_user_urn("data_steward"),
            type=OwnershipTypeClass.BUSINESS_OWNER
        )
    ]
)

# 5. 비즈니스 용어집(Glossary) 연결
glossary_terms = GlossaryTermsClass(
    terms=[
        GlossaryTermAssociationClass(
            urn=make_term_urn("Customer Analytics")
        ),
        GlossaryTermAssociationClass(
            urn=make_term_urn("Marketing Data")
        )
    ],
    auditStamp={"time": 0, "actor": "urn:li:corpuser:admin"}
)

# 6. 도메인 할당
domains = DomainsClass(
    domains=[make_domain_urn("Marketing")]
)

# 7. 태그 추가
global_tags = GlobalTagsClass(
    tags=[
        TagAssociationClass(tag=make_tag_urn("Gold")),
        TagAssociationClass(tag=make_tag_urn("Certified")),
        TagAssociationClass(tag=make_tag_urn("Production"))
    ]
)

# 8. 메타데이터 발행
mcps = [
    MetadataChangeProposalWrapper(entityUrn=dataset_urn, aspect=properties),
    MetadataChangeProposalWrapper(entityUrn=dataset_urn, aspect=schema),
    MetadataChangeProposalWrapper(entityUrn=dataset_urn, aspect=ownership),
    MetadataChangeProposalWrapper(entityUrn=dataset_urn, aspect=glossary_terms),
    MetadataChangeProposalWrapper(entityUrn=dataset_urn, aspect=domains),
    MetadataChangeProposalWrapper(entityUrn=dataset_urn, aspect=global_tags),
]

for mcp in mcps:
    emitter.emit(mcp)

print(f"Dataset registered: {dataset_urn}")

# 9. GraphQL로 메타데이터 검색
import requests

query = """
query {
    search(input: {
        type: DATASET,
        query: "customer",
        start: 0,
        count: 10
    }) {
        searchResults {
            entity {
                urn
                ... on Dataset {
                    name
                    description
                    platform { name }
                }
            }
        }
    }
}
"""

response = requests.post(
    "http://datahub-gms:8080/api/graphql",
    json={"query": query},
    headers={"Authorization": "Bearer your-token"}
)
print(response.json())

Practical Conversation

Analyst: I don't know where the customer data for marketing analysis is. There are so many DW tables that it's hard to find.
Data engineer: Try searching for "customer" in the data catalog. The gold.customer_360 table is the unified customer view. The owner, schema description, and usage examples are all documented.
Analyst: Can I trust this data? How can I tell whether it's up to date?
Data engineer: The catalog has freshness metrics and a data quality score. It has a 95% quality score and updates hourly, and you can also check the source systems in the lineage tab.
Interviewer: What is the value of a data catalog?
Candidate: It shortens data search time, prevents duplicate datasets, provides visibility into data quality, and supports compliance. In Airbnb's case, they reportedly cut data discovery time by 90%. It is essential infrastructure for self-service analytics.
Interviewer: How do you keep metadata up to date?
Candidate: I collect technical metadata through automatic crawling and integrate metadata publishing into the CI/CD pipeline. For business metadata, I include documentation in code reviews, and data stewards review it periodically.

Take a mock interview on this topic → WIA SOOM AI Interview · Start for free

Developer: How do I publish metadata to DataHub for each dbt model?
Senior: Use the dbt-datahub package. After dbt run, model descriptions, column information, and lineage are automatically reflected in DataHub. You can also define owner and tags in the meta field.
Developer: Is there a way to automatically tag PII columns?
Senior: Use DataHub's Classification feature. It automatically detects PII with regex patterns (email, ssn, etc.) and applies tags. You can also integrate it with governance policies for access control.

Cautions

  • If metadata is not up to date, you lose trust. Make automatic crawling and CI/CD integration mandatory.
  • Business metadata (descriptions, tags) requires manual input. Include documentation in the code review process.
  • If user adoption is low, it is useless. Provide sufficient training and onboarding.
  • Integrating with data pipelines (dbt, Airflow) keeps metadata synchronized automatically.
  • Defining the business glossary first enables a consistent understanding of data.

Learn More