External catalog collection

Updated at:

Data Map collects metadata from StarRocks external catalogs indirectly. If you use external catalogs in a StarRocks database, configure the associated data source and run a metadata collection task so that you can search for and view tables, columns, and other metadata in Data Map.

Background

By default, Data Map collects metadata only from the internal catalog of a StarRocks data source. To collect metadata from an external catalog, configure a connection to the associated data source in DataWorks and run a metadata collection task. After collection, Data Map automatically associates the metadata, and you can view the external catalog and its metadata within the StarRocks data source.

Prerequisites

Limitations

  • External catalogs of the Elasticsearch Catalog type are not supported.

  • Paimon Catalogs that use OSS as a source are not supported.

Procedure

The following example uses a MySQL external catalog in StarRocks. If you configure a MySQL database as mysql_catalog_db, you must create a MySQL metadata collector in Data Map. After the collector gathers metadata from the MySQL database, you can search for and view the metadata associated with the mysql_catalog_db catalog in StarRocks.

Step 1: Prepare the data

Create a MySQL data source

Create a MySQL data source with the database name mysql_catalog_db and create a sample table named mysql_catalog_table. The following is a sample script:

CREATE TABLE mysql_catalog_table(
  catalog_table_id INT,
  catalog_table_name VARCHAR(255)
)

Prepare the MySQL JDBC driver package

Upload the MySQL Java Database Connectivity (JDBC) driver for your MySQL version to OSS.

  1. Upload the JDBC driver JAR package for your MySQL version to OSS. Log on to the OSS console. In the left-side navigation pane, click buckets.

  2. Click the name of the destination bucket to open the Manage Files page. This example uses the catalog-bucket-oss bucket.

  3. Click Create Directory to create a directory to store the JAR package. For Folder Name, enter libs.

  4. Go to the directory that you created for the JDBC driver JAR package. Click Upload File. In the Files to Upload area, click Scan for Files, select the mysql-connector-java-8.0.28.jar JDBC driver JAR package, and then click Upload File.

  5. Find the uploaded JDBC driver JAR package. In the Actions column for the file, click Details. On the Details page, click Set ACL. On the Set ACL page, set the file permission to Public Read/Write, and then click OK to enable public access.

Step 2: Configure the external connection

  1. Connect to your StarRocks instance.

    1. Log on to the EMR console. In the left-side navigation pane, choose EMR Serverless > StarRocks. Click Instances.

    2. Find the StarRocks instance that you created and click Actions > Connect to Instance. The New Connection tab appears.

    3. On the New Connection tab, select the Region and Instance name of your StarRocks instance. Enter a Connection Name, Username, and Password. Click Test Network Connectivity. After the connection is successful, click OK to go to the StarRocks instance Query page.

  2. In StarRocks, configure an external catalog for MySQL.

    1. Below the query list, click +File to open the Create File dialog box. Enter a Name, select a Storage Path, and click OK to create the file.

    2. Under All Files, double-click the name of the file that you created to open the StarRocks instance editor. Enter the following sample script to create an external catalog. For more information, see StarRocks external catalog configuration examples.

      CREATE EXTERNAL CATALOG mysql_db_catalog PROPERTIES (
          "driver_class" = "com.mysql.cj.jdbc.Driver", 
          "driver_url" = "https://catalog-bucket-oss.oss-cn-hangzhou-internal.aliyuncs.com/libs/mysql-connector-java-8.0.28.jar", 
          "type" = "jdbc", 
          "user" = "<UserName>", 
          "password"="<PassWord>",
          "jdbc_uri" = "jdbc:mysql://xxx:3306/mysql_catalog_db" );
      Note
      • mysql_db_catalog is the name of the external catalog for the MySQL data source.

      • Replace <UserName> and <PassWord> with your actual credentials.

      • jdbc_uri: Enter the connection URL of the database that you created.

    3. After editing, click Run to run the script. After the script runs successfully, you can view the related table information on the Database tab.

      Click the External Catalog tab. In the Catalog drop-down list, select the catalog you created, such as mysql_db_catalog. You can then expand it to view the corresponding database and table structures.

Step 3: Configure data sources

  1. Log on to the DataWorks console. Switch to the target region. In the left-side navigation pane, click Workspace. In the Workspaces list, find the workspace that you want to manage and click Manage in the Actions column to open the Management Center.

  2. In the left-side navigation pane of the Management Center, click Connection > Data Sources. On the Data Sources page, add StarRocks and MySQL data sources. For more information, see [Deprecated] Configure a StarRocks data source and Configure a MySQL data source.

    Note

    For the MySQL data source, you must select Connection String Mode. This mode is also required for any other JDBC-based external data source.

Step 4: Configure metadata collection

Log on to the DataWorks console. Switch to the target region. In the left-side navigation pane, choose Data Governance > Data Map, and then click Go to Data Map.

Internal catalog collection

Follow the steps in Create a custom collector to create a StarRocks collector.

External catalog collection

You must also complete metadata collection for the MySQL data source. Otherwise, metadata from the MySQL external catalog is not searchable.

Note

In the MySQL metadata collection configuration, set the Data Sources for Which Crawlers Are Created field to MySQL.

Step 5: Search for metadata

After the StarRocks and MySQL metadata collection tasks are complete, click the image search icon on the left to open the search page.

  1. On the Type tab, go to the Connection tab and select the StarRocks data source. Under Filter Conditions, select the StarRocks Instance you created, the external Data Catalog for MySQL, and the corresponding MySQL Database. You can then view the MySQL catalog information within the StarRocks data source.

    The search results show a record for a MySQL catalog table, such as mysql_catalog_table. This indicates that the metadata from the MySQL catalog has been successfully associated with the StarRocks data source.

  2. Alternatively, on the Type tab, go to the Connection tab and select the MySQL data source. Under Filter Conditions, select the name of the MySQL database you created and verify that the table information is consistent.

    The search results show the table records from the MySQL data source, such as mysql_catalog_table. If the table name and the number of records match the results from the StarRocks external catalog search, it confirms that the MySQL data source metadata collection is configured correctly.

  3. View table details.

    Click the target table name to view its details.

    The table details page contains three tabs: Details, Lineage, and Usage Notes. On the Details tab, the Column information section displays the Column name, Type, and Description of each column in a table. For example, the section displays columns such as catalog_table_id (int) and catalog_table_name (varchar).

StarRocks external catalog configuration examples

Use the following syntax to configure a StarRocks external catalog:

CREATE EXTERNAL CATALOG <Catalog_Name> COMMENT '' PROPERTIES("type"="","xxx1"="","xxx2"="");
Note

Catalog_Name is the name of the external data catalog. You can customize this name.

The following table provides examples of how to configure a StarRocks external catalog. For more information, see Data Catalog.

Collection Mode

Connection method

Example

Default Catalog

default

With the Default Catalog type, StarRocks collects its internal metadata by default, so you do not need to configure an external catalog. For more information, see Data analysis.

ODPS Catalog

VPC

CREATE EXTERNAL CATALOG cwy_odps_vpc_hangzhou_catalog PROPERTIES(
    "type"="odps",
    "odps.access.id"="<AccessId>",
    "odps.access.key"="<AccessKey>",
    "odps.endpoint"="http://service.cn-hangzhou-vpc.maxcompute.aliyun-inc.com/api",
    "odps.project"="<ODPSProject>"
);
Note

Replace <AccessId>, <AccessKey>, and <ODPSProject> with your actual values. The value for odps.endpoint in the example is http://service.cn-hangzhou-vpc.maxcompute.aliyun-inc.com/api. You can find the endpoint for your data source's region in the MaxCompute endpoint list. For more information, see Endpoints.

Hive Catalog

Hive Metastore (HMS)

CREATE EXTERNAL CATALOG `hive_catalog_hms` PROPERTIES (
    "hive.metastore.type" = "hive", 
    "hive.metastore.uris" = "thrift://192.xxx.xxx.xxx:9083", 
    "type" = "hive" 
);
Note

Replace the hive.metastore.uris parameter in the example with the value of the corresponding hive.metastore.uris parameter in the hive-site.xml configuration file for your Hive data source.

Data Lake Formation (DLF)

CREATE EXTERNAL CATALOG `hive_catalog_dlf` PROPERTIES (
    "hive.metastore.type" = "dlf", 
    "dlf.catalog.id"="123456",
    "type" = "hive" 
);
Note

Replace the dlf.catalog.id parameter in the example with the value of the corresponding dlf.catalog.id parameter from the hive-site.xml configuration file for your Hive data source.

Iceberg Catalog

Hive

CREATE EXTERNAL CATALOG iceberg_catalog_by_hms 
PROPERTIES (
  "iceberg.catalog.type"  =  "hive",
  "hive.metastore.uris"  =  "thrift://192.xxx.xxx.xxx:9083",
  "type"  =  "iceberg"
);
Note

When you use Hive Metastore as the metadata service and configure an Iceberg external catalog, replace the hive.metastore.uris parameter in the example with the value of the corresponding hive.metastore.uris parameter from the hive-site.xml configuration file of your Hive data source.

Hudi Catalog

Hive

CREATE EXTERNAL CATALOG hudi_catalog_by_hms 
PROPERTIES (
  "hive.metastore.type"  =  "hive",
  "hive.metastore.uris"  =  "thrift://192.xxx.xxx.xxx:9083",
  "type"  =  "hudi"
);
Note

When you use Hive Metastore as the metadata service to configure a Hudi external catalog, replace the hive.metastore.uris parameter in the example with the value of the hive.metastore.uris parameter from the hive-site.xml configuration file of your Hive data source.

Data Lake Formation (DLF)

CREATE EXTERNAL CATALOG hudi_catalog_by_dlf
PROPERTIES (
  "hive.metastore.type" ="dlf",
  "dlf.catalog.id"="123456",
  "type"  =  "hudi"
);
Note

When you use DLF as the metadata service to configure an external Hudi catalog, replace the dlf.catalog.id parameter in the example with the value of the dlf.catalog.id parameter from the hive-site.xml configuration file of your Hive data source.

Delta Lake Catalog

Hive

CREATE EXTERNAL CATALOG `deltalake_hive` PROPERTIES (
    "hive.metastore.type" = "hive", 
    "hive.metastore.uris" = "thrift://192.xxx.xxx.xxx:9083",
    "type" = "deltalake" ,
    "aliyun.oss.access_key" = "<AccessId>",
    "aliyun.oss.secret_key" = "<AccessKey>",
    "aliyun.oss.endpoint" = "<EndPoint>" 
);
Note
  • Replace the hive.metastore.uris parameter in the example with the value of the hive.metastore.uris parameter from your Hive data source's hive-site.xml configuration file.

  • Replace <AccessId> and <AccessKey> with your actual values.

  • For the <EndPoint> parameter, find the value that corresponds to your data source's region in the OSS endpoint list. For more information, see Regions and endpoints. An example value is http://oss-cn-hangzhou-internal.aliyuncs.com.

Data Lake Formation (DLF)

CREATE EXTERNAL CATALOG `deltalake_dlf` PROPERTIES (
    "hive.metastore.type" = "dlf", 
    "dlf.catalog.id"="123456",
    "type" = "deltalake" 
);
Note

Replace the dlf.catalog.id parameter in the example with the value of the dlf.catalog.id parameter in the hive-site.xml configuration file for your Hive data source.

JDBC Catalog

MySQL

CREATE EXTERNAL CATALOG cwy_mysql_db_catalog PROPERTIES (
    "driver_class" = "com.mysql.cj.jdbc.Driver", 
    "driver_url" = "https://bucket-hz.oss-cn-hangzhou-internal.aliyuncs.com/libs/mysql-connector-java-8.0.28.jar", 
    "type" = "jdbc", 
    "user" = "<UserName>", 
    "password"="<PassWord>",
    "jdbc_uri" = "jdbc:mysql://xxx:3306/<database>" );
Note
  • driver_url specifies the storage location of the JDBC driver JAR package in OSS. To upload or download driver files, see Simple download.

  • Replace <UserName> and <PassWord> with your actual credentials.

  • The jdbc_uri parameter specifies the database connection URL, where <database> is the name of the database that you created.

PostgreSQL

CREATE EXTERNAL CATALOG `cwy_postgressql_db_catalog` PROPERTIES (
    "driver_class" = "org.postgresql.Driver", 
    "driver_url" = "https://bucket-hz.oss-cn-hangzhou-internal.aliyuncs.com/libs/postgresql-42.3.3.jar", 
    "type" = "jdbc", 
    "user" = "<UserName>", 
    "password"="<PassWord>",
    "jdbc_uri" = "jdbc:postgresql://xxxx:5432/<database>" );
Note
  • driver_url specifies the storage location of the JDBC driver JAR package in OSS. To upload or download driver files, see Simple download.

  • Replace <UserName> and <PassWord> with your actual credentials.

  • The jdbc_uri parameter specifies the database connection URL, where <database> is the name of the database that you created.

Paimon Catalog

Hive (supported in StarRocks 3.1 and later)

CREATE EXTERNAL CATALOG paimon_by_hive
COMMENT ''
PROPERTIES (
  "type" = "paimon",
  "paimon.catalog.warehouse" = "oss://bucket-hz/paimon_warehouse/",
  "paimon.catalog.type" = "hive",
  "hive.metastore.uris" = "thrift://192.xxx.xxx.xxx:9083"
);
Note

When you use Hive as the metadata service to configure a Paimon Catalog:

  • The paimon.catalog.warehouse parameter specifies the root path of the Paimon data warehouse.

  • Replace the hive.metastore.uris value with the value of the corresponding hive.metastore.uris parameter in the hive-site.xml configuration file of the Hive data source.

Data Lake Formation (DLF, supported in StarRocks 3.1 and later)

CREATE EXTERNAL CATALOG paimon_by_dlf
PROPERTIES (
  "type" = "paimon",
  "paimon.catalog.type" = "dlf",
  "paimon.catalog.warehouse" = "oss://bucket-hz/paimon_warehouse/",
  "aliyun.oss.endpoint" = "<EndPoint>",
  "dlf.catalog.id"="123456"
);
Note

When you use DLF as the metadata service to configure a Paimon Catalog:

  • The paimon.catalog.warehouse parameter specifies the root path of the Paimon data warehouse.

  • For the <EndPoint> parameter, find the value that corresponds to your data source's region in the OSS endpoint list. For more information, see Regions and endpoints. An example value is oss-cn-hangzhou-internal.aliyuncs.com.

  • Replace the dlf.catalog.id parameter in the example with the value of the corresponding dlf.catalog.id parameter from the hive-site.xml configuration file for your Hive data source.

Unified Catalog

Hive (supported in StarRocks 3.2 and later)

CREATE EXTERNAL CATALOG unified_by_dlf
PROPERTIES (
  "type" = "unified",
  "unified.metastore.type" = "hive",
  "hive.metastore.uris" = "thrift://192.xxx.xxx.xxx:9083"
);
Note

If you use Hive as the metadata service when you configure the Unified Catalog, replace the hive.metastore.uris parameter in the example with the value of the corresponding hive.metastore.uris parameter in your Hive data source's hive-site.xml file.