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 SchemaTron CLI

From Leeroopedia
Revision as of 14:44, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Datahub_project_Datahub_SchemaTron_CLI.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Schema_Conversion, CLI_Tooling
Last Updated 2026-02-10 00:00 GMT

Overview

Description

SchemaTron is a Java CLI application that converts Avro schema files into DataHub SchemaMetadata aspects and emits them via configurable sinks. Built with picocli for command-line argument parsing, it supports two emission modes: REST (via RestEmitter) and file (via FileEmitter).

The application processes either a single Avro schema file or an entire directory of .avsc files. For each file, it:

  1. Reads and parses the Avro schema using Apache Avro's Schema.Parser.
  2. Converts the schema to a DataHub SchemaMetadata via AvroSchemaConverter.
  3. Constructs a DatasetUrn from the platform and fully qualified schema name.
  4. Wraps the result in a MetadataChangeProposalWrapper with UPSERT change type.
  5. Emits to the configured sink (REST API or JSON file).

Usage

Invoked as a standalone Java CLI tool for batch conversion of Avro schemas to DataHub metadata. Part of the SchemaTron toolchain alongside the Python avro_schema_to_mce.py script.

Code Reference

Source Location

metadata-integration/java/datahub-schematron/cli/src/main/java/io/datahubproject/schematron/cli/SchemaTron.java

Signature

@Slf4j
@Command(
    name = "schema-translator",
    description = "Converts schemas to DataHub format and emits them",
    mixinStandardHelpOptions = true)
public class SchemaTron implements Callable<Integer> {

    @Option(names = {"-i", "--input"}, description = "Input schema file or directory")
    private String input;

    @Option(names = {"-s", "--server"}, description = "DataHub server URL",
            defaultValue = "http://localhost:8080")
    private String server;

    @Option(names = {"-t", "--token"}, description = "DataHub access token",
            defaultValue = "")
    private String token;

    @Option(names = {"-p", "--platform"}, description = "Data platform name",
            defaultValue = "avro")
    private String platform;

    @Option(names = {"--sink"}, description = "DataHub sink name",
            defaultValue = "rest")
    private String sink;

    @Option(names = {"--output-file"}, description = "Output file for the emitted metadata",
            defaultValue = "metadata.json")
    private String outputFile;

    @Override
    public Integer call() throws Exception

    public static void main(String[] args)
}

Import

import io.datahubproject.schematron.cli.SchemaTron;

I/O Contract

Inputs

Option Type Default Description
-i / --input String (required) Path to an Avro schema file or directory of .avsc files
-s / --server String http://localhost:8080 DataHub GMS server URL
-t / --token String "" DataHub access token for authentication
-p / --platform String "avro" Data platform name for the dataset URN
--sink String "rest" Emission sink: "rest" or "file"
--output-file String "metadata.json" Output file path (only used with file sink)

Outputs

Output Description
REST emission MetadataChangeProposal events sent to the DataHub GMS REST API
File emission JSON file containing serialized metadata change proposals
Exit code 0 on success

Usage Examples

# Convert a single schema and emit via REST
java -jar schematron.jar -i schema.avsc -p kafka -s http://datahub:8080

# Convert a directory of schemas to a file
java -jar schematron.jar -i schemas/ --sink file --output-file metadata.json

# With authentication token
java -jar schematron.jar -i schema.avsc -s http://datahub:8080 -t mytoken

Related Pages

Page Connections

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