OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

Add support for ownership assignment at metadata ingestion level

Open ewaldmikolaj opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe. While ingesting data into OpenMetadata, it's not possible to select the team / user that will be assigned as owner for a given asset. The result of that is, an additional application or manual process is required to add them afterwards.

Describe the solution you'd like I would like to have a possibility to specify Team or User at ingestion pipeline level that would be assigned as an owner after metadata is uploaded into OpenMetadata.

Describe alternatives you've considered Currently, I am running an application scheduled with CRON, that's iterates over Database Schemas and assigns ownership, but this process is slow and could be skipped.

ewaldmikolaj avatar Jul 16 '25 11:07 ewaldmikolaj

Hi @ewaldmikolaj ,

Thanks for proposing this great enhancement.

Just to confirm I'm understanding your proposal correctly, are you thinking we could add an optional owner field under sourceConfig in the ingestion YAML, which would accept the name of a team or a user?

For example, something like this:

source:
  type: mysql
  serviceName: local_mysql
  # ...
  sourceConfig:
    config:
      type: DatabaseMetadata
      # Proposed new field
      owner: "engineering_team"

Code-Eat-Rabbit avatar Sep 23 '25 06:09 Code-Eat-Rabbit

That would be perfect.

ewaldmikolaj avatar Sep 23 '25 16:09 ewaldmikolaj

It would be great if that approach could be applied to other fields like tags or domains. So then every asset ingested by given metadata agent (pipeline) would be automatically enhanced.

ewaldmikolaj avatar Sep 23 '25 16:09 ewaldmikolaj

Hi@ewaldmikolaj, How about this?

OpenMetadata Owner Configuration Guide

Overview

OpenMetadata's owner configuration feature allows you to assign owners to different entities (databases, schemas, tables) during the metadata ingestion process. This feature supports hierarchical configuration, including optional default owners, inheritance mechanisms, and granular table-level configuration.

Key Features

  • Optional Default Owner: Set a default owner for all entities (optional)
  • Hierarchical Configuration: Support for database, schema, and table-level owner configuration
  • Inheritance Mechanism: Child entities can inherit owners from parent entities
  • Precise Matching: Support for FQN (Fully Qualified Name) and simple name matching
  • Override Mechanism: Can update owner information for existing entities
  • Source System Integration: Works seamlessly with existing includeOwners functionality

Configuration Structure

Basic Configuration Format

sourceConfig:
  config:
    type: DatabaseMetadata
    ownerConfig:
      # Optional default owner setting
      default: "default-team"
      
      # Database level configuration
      database:
        "database_name": "database-owner"
      
      # Schema level configuration
      databaseSchema:
        "schema_name": "schema-owner"
      
      # Table level configuration
      table:
        "table_name": "table-owner"
        "another_table": "another-owner"
      
      # Enable inheritance mechanism
      enableInheritance: true
    
    # Enable metadata override
    overrideMetadata: true

Configuration Parameters

Parameter Type Required Description
default string No Default owner used when no other match is found
database object No Database-level owner mapping
databaseSchema object No Schema-level owner mapping
table object No Table-level owner mapping
enableInheritance boolean No Whether to enable inheritance mechanism, default true
overrideMetadata boolean No Whether to override existing metadata, default false

Configuration Modes

Simple Mode

Configure only a default owner:

sourceConfig:
  config:
    type: DatabaseMetadata
    ownerConfig:
      default: "data-engineering-team"

Effect: All databases, schemas, and tables use data-engineering-team as the owner.

Hierarchical Mode

Configure different owners for different levels:

sourceConfig:
  config:
    type: DatabaseMetadata
    ownerConfig:
      default: "data-platform-team"    # Default owner
      database: "database-admins"      # Owner for all databases
      databaseSchema: "schema-owners"  # Owner for all schemas
      table: "table-stewards"          # Owner for all tables
      enableInheritance: true          # Enable inheritance

Effect:

  • All databases have database-admins as owner
  • All schemas have schema-owners as owner
  • All tables have table-stewards as owner

Granular Mode

Configure specific owners for individual entities:

sourceConfig:
  config:
    type: DatabaseMetadata
    ownerConfig:
      default: "data-platform-team"
      database:
        "sales_db": "sales-team"
        "hr_db": "hr-team"
      databaseSchema:
        "public": "public-schema-owner"
        "analytics": "analytics-team"
      table:
        # Using simple table names
        "sales_orders": "sales-team"
        "hr_employees": "hr-team"
        "analytics_reports": "analytics-team"
        
        # Using FQN (Fully Qualified Names) for precise matching
        "sales_db.public.orders": "sales-team"
        "hr_db.employees.personal_info": "hr-team"
        "analytics_db.reporting.monthly_reports": "analytics-team"
      enableInheritance: true

Effect:

  • sales_db database → sales-team
  • hr_db database → hr-team
  • public schema → public-schema-owner
  • analytics schema → analytics-team
  • sales_orders table → sales-team (simple name match)
  • hr_employees table → hr-team (simple name match)
  • analytics_reports table → analytics-team (simple name match)
  • sales_db.public.orders table → sales-team (FQN match)
  • hr_db.employees.personal_info table → hr-team (FQN match)
  • analytics_db.reporting.monthly_reports table → analytics-team (FQN match)

Integration with Source System Owners

The ownerConfig feature works alongside the existing includeOwners configuration:

sourceConfig:
  config:
    type: DatabaseMetadata
    ownerConfig:
      default: "data-team"
      table:
        "important_table1": "specific-owner1"
        "important_table2": "specific-owner2"
      enableInheritance: true
    includeOwners: true  # Enable source system owner extraction

Resolution Order:

  1. ownerConfig takes priority (if configured)
  2. Source system owner is used as fallback (if includeOwners=true and no ownerConfig match)

This integration allows you to:

  • Override source system owners with your own configuration
  • Use source system owners as fallback for unconfigured entities
  • Maintain consistency with your data governance policies

Real-World Test Case

Test Environment Configuration

The following is the complete configuration file used in our actual testing:

source:
  type: mysql
  serviceName: mysql-finance-service
  serviceConnection:
    config:
      type: Mysql
      username: root
      authType:
        password: "your_password_here"
      hostPort: "your_host:3306"
      databaseSchema: 公司财务数据
      connectionOptions: {}
      connectionArguments: {}
  sourceConfig:
    config:
      type: DatabaseMetadata
      # Enable owner configuration feature
      ownerConfig:
        # Set default owner to finance-lab team
        default: "finance-lab"
        
        # Database level owner configuration
        database:
          "公司财务数据": "finance-lab"
        
        # Table level granular owner configuration
        # Assign different users based on table name prefix
        table:
          # Tables starting with 'fi' are assigned to weiyuxin
          "fi_t1": "weiyuxin"
          "fi_t2": "weiyuxin"
          "fi_t3": "weiyuxin"
          "fi_t4": "weiyuxin"
          "fi_t5": "weiyuxin"
          "fi_t6": "weiyuxin"
          "fi_t7": "weiyuxin"
          "fi_t8": "weiyuxin"
          "fi_t9": "weiyuxin"
          "fi_t10": "weiyuxin"
          "fi_t11": "weiyuxin"
          
          # Tables starting with 'fn' are assigned to wangsheng
          "fn_fn046": "wangsheng"
          "fn_fn0461": "wangsheng"
          
          # Tables starting with 'fs' are assigned to lizhuncheng
          "fs_combas": "lizhuncheng"
          "fs_comins": "lizhuncheng"
          "fs_comscfd": "lizhuncheng"
        
        # Enable inheritance so tables without explicit config inherit database owner
        enableInheritance: true
      
      # Other ingestion configuration
      markDeletedTables: true
      markDeletedSchemas: true
      includeTables: true
      includeViews: true
      includeTags: true
      useFqnForFiltering: true
      # Enable metadata override to update owners of existing entities
      overrideMetadata: true

sink:
  type: metadata-rest
  config: {}

workflowConfig:
  # Enable debug logging to see owner resolution process
  loggerLevel: DEBUG
  openMetadataServerConfig:
    hostPort: http://localhost:8585/api
    authProvider: openmetadata
    securityConfig:
      jwtToken: "your_jwt_token_here"

Test Results

image image image image Through the above configuration, we successfully achieved:
  1. Precise owner assignment for 16 tables:

    • 11 tables starting with "fi_" assigned to user "weiyuxin"
    • 2 tables starting with "fn_" assigned to user "wangsheng"
    • 3 tables starting with "fs_" assigned to user "lizhuncheng"
  2. Inheritance mechanism: Tables without explicit configuration inherit the database's default owner "finance-lab"

  3. Override functionality: Successfully updated owner information for existing entities through overrideMetadata: true

Usage Steps

1. Prepare Configuration File

Create or modify your ingestion configuration file based on your database and table structure, adding the ownerConfig section.

2. Set Owner Mappings

Set appropriate owners for different tables based on business requirements:

ownerConfig:
  default: "default-team"  # Optional
  table:
    "sales_data": "sales-team"
    "hr_data": "hr-team"
    "finance_data": "finance-team"

3. Enable Override Mode

If your tables already exist in OpenMetadata, you need to enable override mode:

overrideMetadata: true

4. Run Ingestion

cd /path/to/ingestion
python -m metadata.__main__ --debug ingest -c your_config.yaml

5. Verify Results

Check the owner fields of tables in the OpenMetadata UI to confirm the configuration is correctly applied.

Best Practices

1. Naming Conventions

  • Use meaningful team or user names as owners
  • Maintain naming consistency for easier management

2. Hierarchical Design

  • Prioritize table-level configuration for precise control
  • Leverage inheritance mechanisms to reduce duplicate configuration
  • Consider using default owner as fallback, or omit it for maximum control

3. Debugging Tips

  • Enable DEBUG log level to see owner resolution process
  • Use overrideMetadata: true to ensure updates take effect
  • Check actual results in OpenMetadata UI

4. Configuration Management

  • Separate sensitive information (passwords, tokens) from configuration files
  • Use environment variables or secret management systems
  • Regularly review and update owner configurations

Common Issues and Solutions

Q: Why isn't my owner configuration taking effect?

A: Check the following points:

  1. Ensure overrideMetadata: true is set
  2. Verify that owner names exist in OpenMetadata
  3. Check if table name matching is correct (case-sensitive)
  4. Review DEBUG logs to confirm configuration is correctly parsed

Q: How to configure owners for a large number of tables in bulk?

A: Currently, the system supports exact name matching only. For bulk configuration, you have several options:

Option 1: List all table names explicitly

table:
  "sales_orders": "sales-team"
  "sales_customers": "sales-team"
  "sales_products": "sales-team"
  "hr_employees": "hr-team"
  "hr_departments": "hr-team"
  "finance_reports": "finance-team"
  "finance_budgets": "finance-team"

Option 2: Use inheritance with database/schema level configuration

ownerConfig:
  default: "default-team"
  database:
    "sales_db": "sales-team"
    "hr_db": "hr-team"
    "finance_db": "finance-team"
  enableInheritance: true

Option 3: Use script generation to create the configuration Generate the YAML configuration programmatically based on your table naming patterns.

Q: How does the inheritance mechanism work?

A: When enableInheritance: true:

  1. First look for table-level exact matches
  2. If no match, look for schema-level configuration
  3. Then use database-level configuration
  4. If none found, use default owner (if configured)

Q: How to handle mixed scenarios where some tables need specific owners and others should use source system owners?

A: Configure ownerConfig with specific table owners and enable includeOwners:

ownerConfig:
  table:
    "important_table": "specific-owner"
  enableInheritance: true
sourceConfig:
  config:
    includeOwners: true  # Other tables will use source system owners

The resolution order ensures that ownerConfig takes priority over source system owners.

Q: When should I use FQN vs simple names for table configuration?

A: Use FQN when you need precise control:

ownerConfig:
  table:
    # Use FQN when you have tables with same names in different schemas
    "sales_db.public.orders": "sales-team"
    "analytics_db.public.orders": "analytics-team"
    
    # Use simple names when the table name is unique across your environment
    "unique_table_name": "data-team"

FQN advantages:

  • Precise matching when table names are duplicated across schemas
  • Clear ownership boundaries
  • Better for complex multi-schema environments

Simple name advantages:

  • Shorter configuration
  • Easier to maintain
  • Good for single-schema or unique table names

Technical Implementation

Core Components

  • OwnerResolver: Core class responsible for resolving owner configurations
  • get_owner_from_config: Convenience function handling different types of configuration objects
  • database_service.py: Database ingestion service integrating owner resolution logic

Supported Configuration Types

  • String format (simple mode)
  • Dictionary format (standard mode)
  • Pydantic model (type-safe mode)

Matching Strategy

  1. FQN Matching: Use fully qualified names for exact matching

    • Example: "sales_db.public.orders": "sales-team"
    • Provides precise control when multiple tables have the same name in different schemas
  2. Simple Name Matching: Use table names for matching

    • Example: "orders": "sales-team"
    • Matches any table named "orders" regardless of schema
  3. Inheritance Matching: Inherit owners from parent entities

    • Tables inherit from schema, schemas inherit from database
    • Enabled by default with enableInheritance: true

Resolution Order

The owner resolution follows this priority order (highest to lowest):

Within ownerConfig (handled by OwnerResolver):

  1. Current level custom configuration (exact FQN or name match)
  2. Current level general configuration (string format)
  3. Inherited parent owner (if enableInheritance=true)
  4. Default configuration (if default is configured)

After ownerConfig (handled by database_service.py):

  1. Source system owner (if includeOwners=true and no ownerConfig match found)

Summary

OpenMetadata's owner configuration feature provides flexible and powerful data ownership management capabilities. Through proper configuration, you can achieve:

  • Precise data ownership control
  • Automated owner assignment
  • Hierarchical permission management
  • Easy-to-maintain configuration structure
  • Integration with existing source system owner extraction

This feature is particularly suitable for data governance scenarios in large organizations, effectively improving the standardization and efficiency of data management.

Code-Eat-Rabbit avatar Oct 06 '25 01:10 Code-Eat-Rabbit

I really like that approach, very clean and should help with ownership management. I think it can be extended with other metadata fields later on .

ewaldmikolaj avatar Oct 06 '25 09:10 ewaldmikolaj